Commit 813e4dfd authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

IMAP: use UIDNEXT instead of "*" as interval end when doing full mailbox resync

The opened interval is represented as -1, so when syncing with Microsoft
Exchange the qMin() comparision in the search-in-chunks workaround for
Exchange evaluates as qMin(X, 2^32-1), causing the BatcherFetcher to get
to a loop trying to SEARCH all chunks between 1 and 2^32-1. In practice
Exchange will drop connection at some point, so the folder sync is aborted
and no emails are ever synced.

With this patch we limit the interval end to reported UIDNEXT, so that the
SEARCH loop is finished when we reach the interval with UIDNEXT.

BUG: 351814
FIXED-IN: 15.08.2
parent f50c3473
......@@ -387,7 +387,7 @@ void RetrieveItemsTask::onFinalSelectDone(KJob *job)
}
qCDebug(IMAPRESOURCE_LOG) << "Fetching complete mailbox " << mailBox;
setTotalItems(messageCount);
retrieveItems(KIMAP::ImapSet(1, 0), scope, false, true);
retrieveItems(KIMAP::ImapSet(1, nextUid), scope, false, true);
} else if (nextUid <= 0) {
//This is a compatibilty codepath for Courier IMAP. It probably introduces problems, but at least it syncs.
//Since we don't have uidnext available, we simply use the messagecount. This will miss simultaneously added/removed messages.
......@@ -430,7 +430,7 @@ void RetrieveItemsTask::onFinalSelectDone(KJob *job)
qCWarning(IMAPRESOURCE_LOG) << "Detected inconsistency in local cache, we're missing some messages. Server: " << messageCount << " Local: " << realMessageCount;
qCWarning(IMAPRESOURCE_LOG) << "Refetching complete mailbox.";
setTotalItems(messageCount);
retrieveItems(KIMAP::ImapSet(1, 0), scope, false, true);
retrieveItems(KIMAP::ImapSet(1, nextUid), scope, false, true);
} else if (nextUid > oldNextUid) {
//New messages are available. Fetch new messages, and then check for changed flags and removed messages
qCDebug(IMAPRESOURCE_LOG) << "Fetching new messages: UidNext: " << nextUid << " Old UidNext: " << oldNextUid;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment