aboutsummaryrefslogtreecommitdiff
path: root/internal/feed/cache.go
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2020-08-22 23:34:31 +0200
committerRené 'Necoro' Neumann <necoro@necoro.eu>2020-08-22 23:34:31 +0200
commit057b53113924aa1f0347b6db65a324b49af76551 (patch)
tree0ba1f6d188a9ea64094c1cdefbe91d07d14b2247 /internal/feed/cache.go
parent297a88845eec93f78304b5081a19b9e561652d92 (diff)
downloadfeed2imap-go-057b53113924aa1f0347b6db65a324b49af76551.tar.gz
feed2imap-go-057b53113924aa1f0347b6db65a324b49af76551.tar.bz2
feed2imap-go-057b53113924aa1f0347b6db65a324b49af76551.zip
Pretty up the cache interface; ensure feed2imap-go unlocks the cache
Diffstat (limited to 'internal/feed/cache.go')
-rw-r--r--internal/feed/cache.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/internal/feed/cache.go b/internal/feed/cache.go
index bf64c4a..5f5c394 100644
--- a/internal/feed/cache.go
+++ b/internal/feed/cache.go
@@ -77,7 +77,7 @@ func lock(fileName string) (lock lockfile.Lockfile, err error) {
return
}
-func storeCache(cache Cache, fileName string) error {
+func (cache *Cache) store(fileName string) error {
if cache.CacheImpl == nil {
return fmt.Errorf("trying to store nil cache")
}
@@ -104,15 +104,16 @@ func storeCache(cache Cache, fileName string) error {
writer.Flush()
log.Printf("Stored cache to '%s'.", fileName)
- return UnlockCache(cache)
+ return cache.Unlock()
}
-func UnlockCache(cache Cache) error {
+func (cache *Cache) Unlock() error {
if cache.locked {
if err := cache.lock.Unlock(); err != nil {
return fmt.Errorf("Unlocking cache: %w", err)
}
}
+ cache.locked = false
return nil
}