aerc/worker/imap
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
..
cache.go logging: use level-based logger functions 2022-07-23 22:52:15 +02:00
checkmail.go logging: use level-based logger functions 2022-07-23 22:52:15 +02:00
configure.go imap: add option to cache headers 2022-06-22 11:26:13 +02:00
connect.go lint: apply new formatting rules 2022-08-01 10:44:52 +02:00
create.go go vet: composite literal uses unkeyed fields 2022-03-18 13:33:16 +01:00
fetch.go seqmap: refactor seqmap to use slice instead of map 2022-08-03 22:37:13 +02:00
flags.go imap: remove unused expunge code 2022-07-26 22:24:28 +02:00
idler.go logging: use level-based logger functions 2022-07-23 22:52:15 +02:00
imap.go go.mod: change base git url 2021-11-05 10:21:45 +01:00
list.go lint: apply new formatting rules 2022-08-01 10:44:52 +02:00
movecopy.go lint: apply new formatting rules 2022-08-01 10:44:52 +02:00
observer.go lint: apply new formatting rules 2022-08-01 10:44:52 +02:00
open.go seqmap: refactor seqmap to use slice instead of map 2022-08-03 22:37:13 +02:00
remove.go go vet: composite literal uses unkeyed fields 2022-03-18 13:33:16 +01:00
search.go threading: enable filtering of server-side threads 2022-07-10 21:15:12 +02:00
seqmap.go seqmap: refactor seqmap to use slice instead of map 2022-08-03 22:37:13 +02:00
seqmap_test.go seqmap: refactor seqmap to use slice instead of map 2022-08-03 22:37:13 +02:00
worker.go seqmap: refactor seqmap to use slice instead of map 2022-08-03 22:37:13 +02:00