changeset 19620:9658506bb3ab

imapc: Added imapc_features=fetch-msn-workarounds This can be used to work around broken servers that send invalid MSNs. This avoids errors like: imapc: Mailbox 'INBOX' state corrupted: FETCH UID mismatch (78976 != 82589)
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Sun, 24 Jan 2016 17:39:28 +0200
parents c1ba198e8b50
children 3afca95bb5b5
files src/lib-storage/index/imapc/imapc-mailbox.c src/lib-storage/index/imapc/imapc-settings.c src/lib-storage/index/imapc/imapc-settings.h
diffstat 3 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/imapc/imapc-mailbox.c	Sun Jan 24 17:38:39 2016 +0200
+++ b/src/lib-storage/index/imapc/imapc-mailbox.c	Sun Jan 24 17:39:28 2016 +0200
@@ -222,6 +222,16 @@
 
 	msgmap = imapc_client_mailbox_get_msgmap(mbox->client_box);
 	msg_count = imapc_msgmap_count(msgmap);
+	if (fetch_uid != 0 &&
+	    IMAPC_BOX_HAS_FEATURE(mbox, IMAPC_FEATURE_FETCH_MSN_WORKAROUNDS)) {
+		/* if we know the UID, use own own generated rseq instead of
+		   the potentially broken rseq that the server sent. */
+		uint32_t fixed_rseq;
+
+		if (imapc_msgmap_uid_to_rseq(msgmap, fetch_uid, &fixed_rseq))
+			rseq = fixed_rseq;
+	}
+
 	if (rseq <= msg_count) {
 		uid = imapc_msgmap_rseq_to_uid(msgmap, rseq);
 		if (uid != fetch_uid && fetch_uid != 0) {
--- a/src/lib-storage/index/imapc/imapc-settings.c	Sun Jan 24 17:38:39 2016 +0200
+++ b/src/lib-storage/index/imapc/imapc-settings.c	Sun Jan 24 17:39:28 2016 +0200
@@ -89,6 +89,7 @@
 	{ "zimbra-workarounds", IMAPC_FEATURE_ZIMBRA_WORKAROUNDS },
 	{ "no-examine", IMAPC_FEATURE_NO_EXAMINE },
 	{ "proxyauth", IMAPC_FEATURE_PROXYAUTH },
+	{ "fetch-msn-workarounds", IMAPC_FEATURE_FETCH_MSN_WORKAROUNDS },
 	{ NULL, 0 }
 };
 
--- a/src/lib-storage/index/imapc/imapc-settings.h	Sun Jan 24 17:38:39 2016 +0200
+++ b/src/lib-storage/index/imapc/imapc-settings.h	Sun Jan 24 17:39:28 2016 +0200
@@ -12,7 +12,8 @@
 	IMAPC_FEATURE_SEARCH			= 0x10,
 	IMAPC_FEATURE_ZIMBRA_WORKAROUNDS	= 0x20,
 	IMAPC_FEATURE_NO_EXAMINE		= 0x40,
-	IMAPC_FEATURE_PROXYAUTH			= 0x80
+	IMAPC_FEATURE_PROXYAUTH			= 0x80,
+	IMAPC_FEATURE_FETCH_MSN_WORKAROUNDS	= 0x100
 };
 /* </settings checks> */