From 81eee568f24c14d314969ef1129246bc07c220b8 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 22 May 2019 22:19:11 +0200 Subject: [PATCH] Fix windows file suffix in updater and pmctl --- pmctl/run.go | 11 ++++++++++- updates/updater.go | 10 ++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/pmctl/run.go b/pmctl/run.go index 85fe3972..401f42ad 100644 --- a/pmctl/run.go +++ b/pmctl/run.go @@ -93,6 +93,11 @@ func run(identifier string, cmd *cobra.Command, filterDatabaseFlag bool) error { args = os.Args[3:] } + // adapt identifier + if windows() { + identifier += ".exe" + } + // run for { file, err := getFile(identifier) @@ -101,7 +106,7 @@ func run(identifier string, cmd *cobra.Command, filterDatabaseFlag bool) error { } // check permission - if runtime.GOOS != "windows" { + if !windows() { info, err := os.Stat(file.Path()) if err != nil { return fmt.Errorf("%s failed to get file info on %s: %s", logPrefix, file.Path(), err) @@ -179,3 +184,7 @@ func run(identifier string, cmd *cobra.Command, filterDatabaseFlag bool) error { fmt.Printf("%s %s completed successfully\n", logPrefix, identifier) return nil } + +func windows() bool { + return runtime.GOOS == "windows" +} diff --git a/updates/updater.go b/updates/updater.go index 250719a6..10342971 100644 --- a/updates/updater.go +++ b/updates/updater.go @@ -5,6 +5,7 @@ import ( "errors" "io/ioutil" "path/filepath" + "runtime" "time" "github.com/Safing/portbase/log" @@ -23,8 +24,13 @@ func updater() { func CheckForUpdates() error { - // be sure that pmctl is part of the "used" updates - _, err := GetLocalFile("pmctl/pmctl") + // ensure core components are updated + var err error + if runtime.GOOS == "windows" { + _, err = GetPlatformFile("pmctl/pmctl.exe") + } else { + _, err = GetPlatformFile("pmctl/pmctl") + } if err != nil { log.Errorf("updates: failed to mark pmctl/pmctl as used to ensure updates: %s", err) }