aerc/worker
Tim Culverhouse fdfec2c07a seqmap: refactor seqmap to use slice instead of map
The imap worker's seqmap is represented as a map of sequence number to
UID. This presents a problem when expunging group of messages from the
mailbox: each individual expunge decrements the sequence numbers by 1
(for every sequence number greater than the expunged). This requires a
looping around the map to update the keys. The use of a map also
requires that both the sequence number and the UID of a message be known
in order to insert it into the map. This is only discovered by fetching
individual message body parts (flags, headers, etc), leaving the seqmap
to be empty until we have fetched information about each message. In
certain instances (if a mailbox has recently been loaded), all
information is loaded in memory and no new information is fetched -
leaving the seqmap empty and the UI out of sync with the worker.

Refactor the seqmap as a slice, so that any expunge automatically
decrements the rest of the sequences.

Use the results of FetchDirectoryContents or FetchDirectoryThreaded to
initialize the seqmap with all discovered UIDs. Sort the UIDs in
ascending order: IMAP specification requires that sequence numbers start
at 1 increase in order of ascending UID.

Add individual messages to the map if they come via a MessageUpdate and
have a sequence number larger than our slice.

Update seqmap tests with new logic.

Reference: https://datatracker.ietf.org/doc/html/rfc3501#section-2.3.1.2
Fixes: https://todo.sr.ht/~rjarry/aerc/69
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-03 22:37:13 +02:00
..
handlers go.mod: change base git url 2021-11-05 10:21:45 +01:00
imap seqmap: refactor seqmap to use slice instead of map 2022-08-03 22:37:13 +02:00
lib lint: apply new formatting rules 2022-08-01 10:44:52 +02:00
maildir lint: apply new formatting rules 2022-08-01 10:44:52 +02:00
mbox lint: apply new formatting rules 2022-08-01 10:44:52 +02:00
notmuch lint: apply new formatting rules 2022-08-01 10:44:52 +02:00
types lint: apply new formatting rules 2022-08-01 10:44:52 +02:00
handler_notmuch.go format: reformat code with go 1.17 2021-12-11 23:24:08 +01:00
worker.go logging: use level-based logger functions 2022-07-23 22:52:15 +02:00
worker_enabled.go mbox: implement an mbox backend worker 2022-07-14 23:14:45 +02:00