Fix IMAP sync marking all emails as synced before fetching

Initialize newMaxUids with lastUid instead of mailbox maximum
to prevent marking unfetched emails as synced.

The bug sets newMaxUids to the highest UID before fetching,
causing all existing emails to be skipped when sync state
is saved early.

Fixes #45
This commit is contained in:
Axel Dunkel
2025-08-16 08:43:09 +00:00
parent b4d2125020
commit 6e1dd17267

View File

@@ -189,7 +189,10 @@ export class ImapConnector implements IEmailConnector {
currentMaxUid = lastMessage.uid;
}
}
this.newMaxUids[mailboxPath] = currentMaxUid;
// Initialize with last synced UID, not the maximum UID in mailbox
this.newMaxUids[mailboxPath] = lastUid || 0;
// Only fetch if the mailbox has messages, to avoid errors on empty mailboxes with some IMAP servers.
if (mailbox.exists > 0) {