From 7aa71d334b2755cc5e92fcf83398ce65ede45b40 Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Wed, 15 Jun 2022 07:23:51 -0500 Subject: imap: add option to cache headers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add option to cache headers for imap accounts. Cache db is located at $XDG_CACHE_DIR/aerc/{account name}. The cache is cleaned of stale entries when aerc is first opened. Two new account level configuration options are introduced: * cache-headers (Default: false) * cache-max-age (Default: 30 days (720 hours)) The change in worker/imap/open.go is to set the selected directory. This is required to access the UIDVALIDITY field, which is used in combination with the message ID to form the key for use in the cache db. The key structure is: "header.{UIDVALIDITY}.{UID}" Where reasonable, cache does not stop aerc from running. In general, if there is an error in the cache, aerc should continue working as usual. Errors are either displayed to the user or logged. All messages are stored without flags, and when retrieved have the flags set to SEEN. This is to prevent UI flashes. A new method to FetchMessageFlags is introduced to update flags of cached headers. This is done asynchronously, and the user will see their messages appear and then any flags updated. The message will initially show as SEEN, but will update to unread. I considered updating the cache with the last-known flag state, however it seems prudent to spare the R/W cycle and assume that - eventually - all messages will end up read, and if it isn't the update will occur rather quickly. Note that leveldb puts a lock on the database, preventing multiple instances of aerc from accessing the cache at the same time. Much of this work is based on previous efforts by Vladimír Magyar. Implements: https://todo.sr.ht/~rjarry/aerc/2 Thanks: Vladimír Magyar Signed-off-by: Tim Culverhouse Tested-by: inwit Reviewed-by: Koni Marti Acked-by: Robin Jarry --- go.mod | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'go.mod') diff --git a/go.mod b/go.mod index a3b32be..0affccb 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.13 require ( git.sr.ht/~sircmpwn/getopt v1.0.0 github.com/ProtonMail/go-crypto v0.0.0-20211221144345-a4f6767435ab - github.com/arran4/golang-ical v0.0.0-20220517104411-fd89fefb0182 // indirect + github.com/arran4/golang-ical v0.0.0-20220517104411-fd89fefb0182 github.com/creack/pty v1.1.17 github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 github.com/ddevault/go-libvterm v0.0.0-20190526194226-b7d861da3810 @@ -18,7 +18,7 @@ require ( github.com/emersion/go-sasl v0.0.0-20211008083017-0b9dcfb154ac github.com/emersion/go-smtp v0.15.0 github.com/fsnotify/fsnotify v1.5.1 - github.com/gatherstars-com/jwz v1.3.0 // indirect + github.com/gatherstars-com/jwz v1.3.0 github.com/gdamore/tcell/v2 v2.4.0 github.com/go-ini/ini v1.63.2 github.com/golang/protobuf v1.5.2 // indirect @@ -35,7 +35,8 @@ require ( github.com/pkg/errors v0.9.1 github.com/riywo/loginshell v0.0.0-20200815045211-7d26008be1ab github.com/stretchr/testify v1.7.1 - github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect + github.com/syndtr/goleveldb v1.0.0 + github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 github.com/zenhack/go.notmuch v0.0.0-20211022191430-4d57e8ad2a8b golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 // indirect golang.org/x/net v0.0.0-20211029224645-99673261e6eb // indirect -- cgit v1.2.3