[Fix]: Large purge failures

I swear writing a tempmail service is hard
This commit is contained in:
ClaraCrazy 2026-01-08 11:06:45 +01:00
parent f8ce98a584
commit b8b198125d
No known key found for this signature in database
GPG key ID: EBBC896ACB497011

View file

@ -296,11 +296,15 @@ class ImapService extends EventEmitter {
}
debug(`Deleting mails ${toDelete}`);
await this.connection.deleteMessage(toDelete);
toDelete.forEach(uid => {
this.emit(ImapService.EVENT_DELETED_MAIL, uid);
});
// Batch deletes to avoid IMAP argument limits
const BATCH_SIZE = 100;
for (let i = 0; i < toDelete.length; i += BATCH_SIZE) {
const batch = toDelete.slice(i, i + BATCH_SIZE);
await this.connection.deleteMessage(batch);
batch.forEach(uid => {
this.emit(ImapService.EVENT_DELETED_MAIL, uid);
});
}
}