Skip to content

Commit

Permalink
imapc: Added imapc_features=fetch-msn-workarounds
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
sirainen committed Jan 24, 2016
1 parent e9d659a commit 53841bd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/lib-storage/index/imapc/imapc-mailbox.c
Expand Up @@ -222,6 +222,16 @@ imapc_mailbox_msgmap_update(struct imapc_mailbox *mbox,

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) {
Expand Down
1 change: 1 addition & 0 deletions src/lib-storage/index/imapc/imapc-settings.c
Expand Up @@ -89,6 +89,7 @@ static const struct imapc_feature_list imapc_feature_list[] = {
{ "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 }
};

Expand Down
3 changes: 2 additions & 1 deletion src/lib-storage/index/imapc/imapc-settings.h
Expand Up @@ -12,7 +12,8 @@ enum imapc_features {
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> */

Expand Down

0 comments on commit 53841bd

Please sign in to comment.