fix(mail): targeted + batch expunge in ImapClient (avoid deleting unrelated \Deleted mail) #295

Closed
opened 2026-07-04 06:46:34 +00:00 by JMR-dev · 0 comments
JMR-dev commented 2026-07-04 06:46:34 +00:00 (Migrated from github.com)

Phase-3 review finding (MEDIUM/data-loss + efficiency). ImapClient.deleteMessage(:357)/moveMessages(:384) flag the target \Deleted then call the untargeted mailbox.expunge(), which permanently removes EVERY \Deleted-flagged message in the folder — not just the intended UIDs (data-loss window with a 2nd client, on Gmail, or after a partial prior move). Also: repo batch paths call single-UID deleteMessage in a loop → N sequential IMAP logins + N expunges for an N-message selection. Fix: add a batch deleteMessages(uids) that opens once, setFlags(msgs, \Deleted), and does a single targeted IMAPFolder.expunge(Message[]) (UID EXPUNGE, RFC 4315); route repo batch deletes/expunge through it. Test via GreenMail. Fixes both the data-loss and the N-login inefficiency.

Phase-3 review finding (MEDIUM/data-loss + efficiency). `ImapClient.deleteMessage`(:357)/`moveMessages`(:384) flag the target `\Deleted` then call the **untargeted** `mailbox.expunge()`, which permanently removes EVERY `\Deleted`-flagged message in the folder — not just the intended UIDs (data-loss window with a 2nd client, on Gmail, or after a partial prior move). Also: repo batch paths call single-UID `deleteMessage` in a loop → **N sequential IMAP logins + N expunges** for an N-message selection. **Fix:** add a batch `deleteMessages(uids)` that opens once, `setFlags(msgs, \Deleted)`, and does a single **targeted** `IMAPFolder.expunge(Message[])` (UID EXPUNGE, RFC 4315); route repo batch deletes/expunge through it. Test via GreenMail. Fixes both the data-loss and the N-login inefficiency.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: JMR-dev/LibreMail#295