diff --git a/app/src/main/java/com/sun/mail/imap/IMAPFolder.java b/app/src/main/java/com/sun/mail/imap/IMAPFolder.java index d8d80fac02..08b64967d6 100644 --- a/app/src/main/java/com/sun/mail/imap/IMAPFolder.java +++ b/app/src/main/java/com/sun/mail/imap/IMAPFolder.java @@ -4072,18 +4072,21 @@ public class IMAPFolder extends Folder implements UIDFolder, ResponseHandler { eu.faircode.email.Log.w("Sequence=" + seqnum); return null; } - if (seqnum > messageCache.size()) { + if (seqnum > realTotal) { // Microsoft Exchange will sometimes return message // numbers that it has not yet notified the client // about via EXISTS; ignore those messages here. // GoDaddy IMAP does this too. // Mailfence + // Yahoo when > 10,000 messages if (logger.isLoggable(Level.FINE)) logger.fine("ignoring message number " + seqnum + " outside range " + messageCache.size()); - int count = seqnum - messageCache.size(); - eu.faircode.email.Log.w("Adding sequence=" + seqnum + " count=" + count); - messageCache.addMessages(count, seqnum - count + 1); + int count = seqnum - realTotal; + eu.faircode.email.Log.w("Adding sequence=" + seqnum + " count=" + count + " total=" + realTotal); + messageCache.addMessages(count, realTotal + 1); + realTotal += count; + total += count; //return null; } return messageCache.getMessageBySeqnum(seqnum);