aerc/worker/imap
Tim Culverhouse 7aa71d334b imap: add option to cache headers
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 <vladimir@mgyar.me>
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Tested-by: inwit <inwit@sindominio.net>
Reviewed-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-06-22 11:26:13 +02:00
..
cache.go imap: add option to cache headers 2022-06-22 11:26:13 +02:00
checkmail.go feat: add background mail polling option for all workers 2022-05-31 14:32:51 +02:00
configure.go imap: add option to cache headers 2022-06-22 11:26:13 +02:00
connect.go imap: add timeout to tcp connect functions 2022-05-04 14:07:15 +02:00
create.go go vet: composite literal uses unkeyed fields 2022-03-18 13:33:16 +01:00
fetch.go imap: add option to cache headers 2022-06-22 11:26:13 +02:00
flags.go logging: added a log on panic 2022-03-23 20:56:09 +01:00
idler.go imap: add debouncer to the idler 2022-05-04 14:07:15 +02:00
imap.go go.mod: change base git url 2021-11-05 10:21:45 +01:00
list.go logging: added a log on panic 2022-03-23 20:56:09 +01:00
movecopy.go dirlist: update RUE counts for imap/maildir on move|copy|delete|archive 2022-06-07 16:19:23 +02:00
observer.go imap: monitor the logout channel with an observer 2022-05-04 14:07:15 +02:00
open.go imap: add option to cache headers 2022-06-22 11:26:13 +02:00
remove.go go vet: composite literal uses unkeyed fields 2022-03-18 13:33:16 +01:00
search.go Add flag based search options 2020-07-25 08:08:08 +02:00
worker.go imap: add option to cache headers 2022-06-22 11:26:13 +02:00