diff options
author | Robin Jarry <robin@jarry.cc> | 2023-04-26 23:49:40 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-04-27 10:28:46 +0200 |
commit | c65f7dca01872ce17491ffb3240993d3b60e1e96 (patch) | |
tree | 9cb5f84bd5ae4f8f7b3f5378436bc69da9a04c6d /worker/imap | |
parent | 9959db8d1cfe2bf73309435128d7986b9dd2a1c1 (diff) | |
download | aerc-c65f7dca01872ce17491ffb3240993d3b60e1e96.tar.gz |
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>
Diffstat (limited to 'worker/imap')
-rw-r--r-- | worker/imap/cache.go | 6 |
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)) |