diff options
author | Tim Culverhouse <tim@timculverhouse.com> | 2023-04-30 12:56:10 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-05-16 17:07:50 +0200 |
commit | 6b6aaf3ae131971d05ab3f849ea3db14c6a6e055 (patch) | |
tree | 00f9055556388cf1396af6da84ef0b5b59814efe /worker/maildir/worker.go | |
parent | e8089e7d8f6065031814bf7d80be043536e09fe7 (diff) | |
download | aerc-6b6aaf3ae131971d05ab3f849ea3db14c6a6e055.tar.gz |
headers: enable partial header fetching
Enable partial header fetching by creating config values for headers to
specifically include, or specifically exclude. The References field will
always be fetched, regardless of the include list. Envelope data is
always fetched, but is not shown with :toggle-headers, since it isn't in
the RFC822 struct unless explicitly included in the list.
Partial headers can break the cache on changes. Update the cache tag key
to include the state of the partially-fetched headers.
Partial header fetching can have a significant performance increase for
IMAP, and for all backends a resource improvement. Some data to support
this is below. Gathered by opening aerc, selecting a mailbox with
approximately 800 messages and scrolling to the end.
Received measured with nethogs, RAM from btop
Received | RAM
-------------------------------------
All Headers | 9,656 kb | 103 MB
Minimum Headers | 896 kb | 36 MB
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'worker/maildir/worker.go')
-rw-r--r-- | worker/maildir/worker.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/worker/maildir/worker.go b/worker/maildir/worker.go index b222aab8..c45992eb 100644 --- a/worker/maildir/worker.go +++ b/worker/maildir/worker.go @@ -47,6 +47,8 @@ type Worker struct { currentSortCriteria []*types.SortCriterion maildirpp bool // whether to use Maildir++ directory layout capabilities *models.Capabilities + headers []string + headersExclude []string } // NewWorker creates a new maildir worker with the provided worker. @@ -349,6 +351,8 @@ func (w *Worker) handleConfigure(msg *types.Configure) error { if err != nil { return err } + w.headers = msg.Config.Headers + w.headersExclude = msg.Config.HeadersExclude log.Debugf("configured base maildir: %s", dir) return nil } @@ -620,6 +624,12 @@ func (w *Worker) handleFetchMessageHeaders( w.worker.PostMessageInfoError(msg, uid, err) continue } + switch { + case len(w.headersExclude) > 0: + lib.LimitHeaders(info.RFC822Headers, w.headersExclude, true) + case len(w.headers) > 0: + lib.LimitHeaders(info.RFC822Headers, w.headers, false) + } w.worker.PostMessage(&types.MessageInfo{ Message: types.RespondTo(msg), Info: info, |