aboutsummaryrefslogtreecommitdiff
path: root/internal/feed/cache/cache.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--internal/feed/cache/cache.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/internal/feed/cache/cache.go b/internal/feed/cache/cache.go
index 9613f06..1ea8eaf 100644
--- a/internal/feed/cache/cache.go
+++ b/internal/feed/cache/cache.go
@@ -18,7 +18,7 @@ import (
type Version byte
const (
- currentVersion Version = v1Version
+ currentVersion Version = v2Version
)
type Impl interface {
@@ -56,6 +56,8 @@ func forVersion(version Version) (Impl, error) {
switch version {
case v1Version:
return newV1Cache(), nil
+ case v2Version:
+ return newV2Cache(), nil
default:
return nil, fmt.Errorf("unknown cache version '%d'", version)
}
@@ -169,11 +171,15 @@ func Load(fileName string) (Cache, error) {
return Cache{}, fmt.Errorf("decoding for version '%d' from '%s': %w", version, fileName, err)
}
- if cache, err = cache.transformTo(currentVersion); err != nil {
- return Cache{}, fmt.Errorf("cannot transform from version %d to %d: %w", version, currentVersion, err)
- }
+ if 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)
+ }
- log.Printf("Loaded cache (version %d), transformed to version %d.", version, currentVersion)
+ log.Printf("Loaded cache (version %d), transformed to version %d.", version, currentVersion)
+ } else {
+ log.Printf("Loaded cache (version %d)", version)
+ }
return Cache{cache, lock, true}, nil
}
03273212259b9039c9356a6ed90f&follow=1'>Fix compatibility with GnuPG 2.2.19Andreas Stieger2-2/+2 2017-03-01tests: fix on OSX by not using the tr hackJason A. Donenfeld3-5/+2 2017-02-26Bump version1.7Jason A. Donenfeld1-1/+1 2017-02-26Modernize makefileJason A. Donenfeld2-31/+36 2017-02-25CopyrightJason A. Donenfeld1-1/+1 2017-02-25StyleJason A. Donenfeld1-2/+2 2017-02-25git: use inner-most directoryJason A. Donenfeld2-27/+48 2017-02-25clip: sleep may require argv[0] to be sleepJason A. Donenfeld1-1/+1 2017-02-25man: document system extensionsJason A. Donenfeld1-2/+3