summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-04-26 23:49:40 +0200
committerRobin Jarry <robin@jarry.cc>2023-04-27 10:28:46 +0200
commitc65f7dca01872ce17491ffb3240993d3b60e1e96 (patch)
tree9cb5f84bd5ae4f8f7b3f5378436bc69da9a04c6d
parent9959db8d1cfe2bf73309435128d7986b9dd2a1c1 (diff)
downloadaerc-c65f7dca01872ce17491ffb3240993d3b60e1e96.tar.gz
aerc-c65f7dca01872ce17491ffb3240993d3b60e1e96.zip
imap: avoid error log when pruning cache entries
Avoid such errors in the logs: ERROR cache.go:187: cannot clean database 0: unexpected EOF The cache now contains a tag mapped to a special key. This is not a gob serialized cached header. Ignore it when pruning old cache entries. Fixes: 6ea0f18635a8 ("imap: clear cache on tag mismatch") Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
-rw-r--r--worker/imap/cache.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/worker/imap/cache.go b/worker/imap/cache.go
index 94cebb92..a02f2cae 100644
--- a/worker/imap/cache.go
+++ b/worker/imap/cache.go
@@ -8,7 +8,6 @@ import (
"fmt"
"os"
"path"
- "reflect"
"time"
"git.sr.ht/~rjarry/aerc/lib/parse"
@@ -61,7 +60,7 @@ func (w *IMAPWorker) initCacheDb(acct string) {
tag, err := w.cache.Get(cacheTagKey, nil)
clearCache := errors.Is(err, leveldb.ErrNotFound) ||
- !reflect.DeepEqual(tag, cacheTag)
+ !bytes.Equal(tag, cacheTag)
switch {
case clearCache:
log.Infof("current cache tag is '%s' but found '%s'",
@@ -179,6 +178,9 @@ func (w *IMAPWorker) cleanCache(path string) {
var scanned, removed int
iter := w.cache.NewIterator(nil, nil)
for iter.Next() {
+ if bytes.Equal(iter.Key(), cacheTagKey) {
+ continue
+ }
data := iter.Value()
ch := &CachedHeader{}
dec := gob.NewDecoder(bytes.NewReader(data))