worker/imap: Fix seqMap race condition

When deleting a message, sometimes FetchDirectoryContents will fire.
FetchDirectoryContents will return a smaller set of UIDs since messages
have been deleted. This operation races with fetching from the seqMap in
client.ExpungeUpdate. Only recreate the seqMap if it can grow so that
messages will continue to be expunged.

Signed-off-by: Kevin Kuehler <keur@xcf.berkeley.edu>
This commit is contained in:
Kevin Kuehler 2019-11-10 14:17:55 -08:00 committed by Drew DeVault
parent 08574104bc
commit 8a848303fe

View file

@ -40,7 +40,9 @@ func (imapw *IMAPWorker) handleFetchDirectoryContents(
}, nil)
} else {
imapw.worker.Logger.Printf("Found %d UIDs", len(uids))
imapw.seqMap = make([]uint32, len(uids))
if len(imapw.seqMap) < len(uids) {
imapw.seqMap = make([]uint32, len(uids))
}
imapw.worker.PostMessage(&types.DirectoryContents{
Message: types.RespondTo(msg),
Uids: uids,