]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imapc: Fix expunges+appends in same session with imapc_features=no-msn-updates
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 17 Apr 2018 12:46:41 +0000 (15:46 +0300)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Wed, 18 Apr 2018 08:57:28 +0000 (11:57 +0300)
Since the EXPUNGEs were ignored, the sequence numbers weren't updated.
When a new mail arrived, the sequence number sent by the remote IMAP server
pointed to existing mails in imapc's mapping. Fix this by changing the
sequence number if the returned UID is >= next_uid.

Fixes "FETCH UID mismatch" errors.

src/lib-storage/index/imapc/imapc-mailbox.c

index 24bf4ba60b6db7bb8297eb6c64c3a6de90bbe88b..0a1bb6e0fa861e3b8617605ab5e7c73c7110b840 100644 (file)
@@ -372,6 +372,14 @@ imapc_mailbox_msgmap_update(struct imapc_mailbox *mbox,
 
                if (imapc_msgmap_uid_to_rseq(msgmap, fetch_uid, &fixed_rseq))
                        rseq = fixed_rseq;
+               else if (fetch_uid >= imapc_msgmap_uidnext(msgmap) &&
+                        rseq <= msg_count) {
+                       /* The current rseq is wrong. Lets hope that the
+                          correct rseq is the next new one. This happens
+                          especially with no-msn-updates when mails have been
+                          expunged and new mails arrive in the same session. */
+                       rseq = msg_count+1;
+               }
        }
 
        if (rseq <= msg_count) {