From c6332dda7daf11750117a4c501f1e8c5eb09b9e2 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 30 Jul 2019 13:07:33 +0200 Subject: [PATCH] Fix paths and identifiers --- updates/get.go | 2 +- updates/main.go | 4 +++- updates/notify.go | 14 +++++++++----- updates/updater.go | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/updates/get.go b/updates/get.go index 9d4b7ac8..f0c74c07 100644 --- a/updates/get.go +++ b/updates/get.go @@ -83,7 +83,7 @@ func loadOrFetchFile(identifier string, fetch bool) (*File, error) { } // check download dir - err := utils.EnsureDirectory(downloadTmpPath, 0755) + err := utils.EnsureDirectory(downloadTmpPath, 0700) if err != nil { return nil, fmt.Errorf("could not prepare tmp directory for download: %s", err) } diff --git a/updates/main.go b/updates/main.go index b8ce1071..19a48eed 100644 --- a/updates/main.go +++ b/updates/main.go @@ -4,6 +4,7 @@ import ( "errors" "os" "path/filepath" + "runtime" "github.com/safing/portbase/database" "github.com/safing/portbase/info" @@ -15,6 +16,7 @@ import ( var ( updateStoragePath string downloadTmpPath string + isWindows = runtime.GOOS == "windows" ) // SetDatabaseRoot tells the updates module where the database is - and where to put its stuff. @@ -66,7 +68,7 @@ func start() error { err = UpdateIndexes() if err != nil { - return err + log.Errorf("updates: failed to download update index: %s", err) } } else { return err diff --git a/updates/notify.go b/updates/notify.go index 398018bd..bbfa9f18 100644 --- a/updates/notify.go +++ b/updates/notify.go @@ -12,21 +12,25 @@ const coreIdentifier = "core/portmaster-core" var lastNotified time.Time func updateNotifier() { - time.Sleep(30 * time.Second) + time.Sleep(5 * time.Minute) for { + ident := coreIdentifier + if isWindows { + ident += ".exe" + } - _, version, _, ok := getLatestFilePath(coreIdentifier) - if ok { + file, err := GetLocalPlatformFile(ident) + if err == nil { status.Lock() liveVersion := status.Core.Version status.Unlock() - if version != liveVersion { + if file.Version() != liveVersion { // create notification (¬ifications.Notification{ ID: "updates-core-update-available", - Message: fmt.Sprintf("There is an update available for the Portmaster core (v%s), please restart the Portmaster to apply the update.", version), + Message: fmt.Sprintf("There is an update available for the Portmaster core (v%s), please restart the Portmaster to apply the update.", file.Version()), Type: notifications.Info, Expires: time.Now().Add(1 * time.Minute).Unix(), }).Init().Save() diff --git a/updates/updater.go b/updates/updater.go index 9ef17788..bfe883eb 100644 --- a/updates/updater.go +++ b/updates/updater.go @@ -153,7 +153,7 @@ func DownloadUpdates() (err error) { log.Tracef("updates: finished updating existing files") // remove tmp folder after we are finished - err = os.RemoveAll(updateStoragePath) + err = os.RemoveAll(downloadTmpPath) if err != nil { log.Tracef("updates: failed to remove tmp dir %s after downloading updates: %s", updateStoragePath, err) }