changeset 22764:74dc3b764627

imapc: Add imapc_features=no-msn-updates This is a stricter version of fetch-msn-workarounds. The MSNs aren't trusted at all. This means any new untagged EXISTS and EXPUNGE replies are ignored, as well as untagged FETCH replies that don't include UID. A potential downside with this feature is that UID FETCH/STORE commands sent to expunged messages will likely fail without the IMAP client being notified of the EXPUNGEs. New mails are also not noticed, so this should be used only when it's known that the clients don't keep the connection open for long.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Mon, 25 Dec 2017 11:10:19 +0200
parents c7cb96a96e2d
children ed02e59a449c
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, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/imapc/imapc-mailbox.c	Mon Dec 25 16:11:26 2017 +0200
+++ b/src/lib-storage/index/imapc/imapc-mailbox.c	Mon Dec 25 11:10:19 2017 +0200
@@ -274,7 +274,7 @@
 	uint32_t exists_count = reply->num;
 	const struct mail_index_header *hdr;
 
-	if (mbox == NULL)
+	if (mbox == NULL || IMAPC_BOX_HAS_FEATURE(mbox, IMAPC_FEATURE_NO_MSN_UPDATES))
 		return;
 
 	mbox->exists_count = exists_count;
@@ -352,7 +352,8 @@
 	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)) {
+	    (IMAPC_BOX_HAS_FEATURE(mbox, IMAPC_FEATURE_FETCH_MSN_WORKAROUNDS) ||
+	     IMAPC_BOX_HAS_FEATURE(mbox, IMAPC_FEATURE_NO_MSN_UPDATES))) {
 		/* if we know the UID, use own own generated rseq instead of
 		   the potentially broken rseq that the server sent. */
 		uint32_t fixed_rseq;
@@ -474,6 +475,11 @@
 			}
 		}
 	}
+	if (fetch_uid == 0 &&
+	    IMAPC_BOX_HAS_FEATURE(mbox, IMAPC_FEATURE_NO_MSN_UPDATES)) {
+		/* UID missing and we're not tracking MSNs */
+		return;
+	}
 
 	imapc_mailbox_init_delayed_trans(mbox);
 	if (imapc_mailbox_msgmap_update(mbox, rseq, fetch_uid,
@@ -576,7 +582,8 @@
 	struct imapc_msgmap *msgmap;
 	uint32_t lseq, uid, rseq = reply->num;
 	
-	if (mbox == NULL || rseq == 0)
+	if (mbox == NULL || rseq == 0 ||
+	    IMAPC_BOX_HAS_FEATURE(mbox, IMAPC_FEATURE_NO_MSN_UPDATES))
 		return;
 
 	mbox->prev_skipped_rseq = 0;
--- a/src/lib-storage/index/imapc/imapc-settings.c	Mon Dec 25 16:11:26 2017 +0200
+++ b/src/lib-storage/index/imapc/imapc-settings.c	Mon Dec 25 11:10:19 2017 +0200
@@ -103,6 +103,7 @@
 	{ "delay-login", IMAPC_FEATURE_DELAY_LOGIN },
 	{ "fetch-bodystructure", IMAPC_FEATURE_FETCH_BODYSTRUCTURE },
 	{ "fetch-empty-is-expunged", IMAPC_FEATURE_FETCH_EMPTY_IS_EXPUNGED },
+	{ "no-msn-updates", IMAPC_FEATURE_NO_MSN_UPDATES },
 	{ NULL, 0 }
 };
 
--- a/src/lib-storage/index/imapc/imapc-settings.h	Mon Dec 25 16:11:26 2017 +0200
+++ b/src/lib-storage/index/imapc/imapc-settings.h	Mon Dec 25 11:10:19 2017 +0200
@@ -19,6 +19,7 @@
 	IMAPC_FEATURE_DELAY_LOGIN		= 0x800,
 	IMAPC_FEATURE_FETCH_BODYSTRUCTURE	= 0x1000,
 	IMAPC_FEATURE_FETCH_EMPTY_IS_EXPUNGED	= 0x4000,
+	IMAPC_FEATURE_NO_MSN_UPDATES		= 0x8000,
 };
 /* </settings checks> */