From 297a88845eec93f78304b5081a19b9e561652d92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Sat, 22 Aug 2020 23:12:54 +0200 Subject: print-cache should also unlock --- internal/feed/cache.go | 6 +++++- tools/print-cache/print-cache.go | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/feed/cache.go b/internal/feed/cache.go index fa22139..bf64c4a 100644 --- a/internal/feed/cache.go +++ b/internal/feed/cache.go @@ -104,8 +104,12 @@ func storeCache(cache Cache, fileName string) error { writer.Flush() log.Printf("Stored cache to '%s'.", fileName) + return UnlockCache(cache) +} + +func UnlockCache(cache Cache) error { if cache.locked { - if err = cache.lock.Unlock(); err != nil { + if err := cache.lock.Unlock(); err != nil { return fmt.Errorf("Unlocking cache: %w", err) } } diff --git a/tools/print-cache/print-cache.go b/tools/print-cache/print-cache.go index d20963a..b21643e 100644 --- a/tools/print-cache/print-cache.go +++ b/tools/print-cache/print-cache.go @@ -27,6 +27,8 @@ func main() { log.Fatal(err) } + defer func() {_ = feed.UnlockCache(cache)}() + fmt.Printf("Cache version %d\n", cache.Version()) if feedId != "" { fmt.Print(cache.SpecificInfo(feedId)) -- cgit v1.2.3