From 3c53a2162c26350ed1544d2c8631dc7db6dec4ca Mon Sep 17 00:00:00 2001 From: Andrey Meshkov Date: Tue, 21 Jul 2020 12:17:23 +0300 Subject: [PATCH] added version cache --- update/updater.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/update/updater.go b/update/updater.go index 5e8cdbcf..32a092ca 100644 --- a/update/updater.go +++ b/update/updater.go @@ -3,6 +3,7 @@ package update import ( "os" "path/filepath" + "time" ) type Updater struct { @@ -10,13 +11,19 @@ type Updater struct { currentBinary string // current binary executable workDir string // updater work dir (where backup/upd dirs will be created) + + // cached version.json to avoid hammering github.io for each page reload + versionCheckJSON []byte + versionCheckLastTime time.Time } // NewUpdater - creates a new instance of the Updater func NewUpdater(workDir string) *Updater { return &Updater{ - currentBinary: filepath.Base(os.Args[0]), - workDir: workDir, + currentBinary: filepath.Base(os.Args[0]), + workDir: workDir, + versionCheckJSON: nil, + versionCheckLastTime: time.Time{}, } }