From 21210173c4d04676436b8e48dfbe4043299797cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Sat, 27 Feb 2021 23:29:04 +0100 Subject: Do not upgrade the cache in `print-cache` --- internal/feed/cache/cache.go | 4 ++-- internal/feed/cache/state.go | 2 +- tools/print-cache/print-cache.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/feed/cache/cache.go b/internal/feed/cache/cache.go index 1ea8eaf..171d0cb 100644 --- a/internal/feed/cache/cache.go +++ b/internal/feed/cache/cache.go @@ -138,7 +138,7 @@ func create() (Cache, error) { }, nil } -func Load(fileName string) (Cache, error) { +func Load(fileName string, upgrade bool) (Cache, error) { f, err := os.Open(fileName) if err != nil { if errors.Is(err, os.ErrNotExist) { @@ -171,7 +171,7 @@ func Load(fileName string) (Cache, error) { return Cache{}, fmt.Errorf("decoding for version '%d' from '%s': %w", version, fileName, err) } - if currentVersion != cache.Version() { + if upgrade && currentVersion != cache.Version() { if cache, err = cache.transformTo(currentVersion); err != nil { return Cache{}, fmt.Errorf("cannot transform from version %d to %d: %w", version, currentVersion, err) } diff --git a/internal/feed/cache/state.go b/internal/feed/cache/state.go index 3a40878..2df0c74 100644 --- a/internal/feed/cache/state.go +++ b/internal/feed/cache/state.go @@ -45,7 +45,7 @@ func (state *State) LoadCache(fileName string, forceNew bool) error { if forceNew { cache, err = create() } else { - cache, err = Load(fileName) + cache, err = Load(fileName, true) } if err != nil { diff --git a/tools/print-cache/print-cache.go b/tools/print-cache/print-cache.go index c00bf51..ef1d8e5 100644 --- a/tools/print-cache/print-cache.go +++ b/tools/print-cache/print-cache.go @@ -22,7 +22,7 @@ func init() { func main() { flag.Parse() - cache, err := cache.Load(cacheFile) + cache, err := cache.Load(cacheFile, false) if err != nil { log.Fatal(err) } -- cgit v1.2.3