From 478ea877f9794233b3ea24cf28aa07295ae71fad Mon Sep 17 00:00:00 2001 From: Agent Zero Date: Mon, 20 Jul 2026 12:40:27 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20stop=20restoring=20soft-deleted=20mails?= =?UTF-8?q?=20during=20sync=20=E2=80=94=20they=20stay=20deleted?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Removed restore logic from imap_sync_account and imap_sync_folder - Soft-deleted mails are now skipped during sync (not touched, not restored) - This prevents deleted mails from reappearing when they are found on IMAP - The sync queue handles retrying failed IMAP deletes --- app/plugins/builtins/mail/services.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/plugins/builtins/mail/services.py b/app/plugins/builtins/mail/services.py index 114ca1c..06ae2ac 100644 --- a/app/plugins/builtins/mail/services.py +++ b/app/plugins/builtins/mail/services.py @@ -636,8 +636,9 @@ async def imap_sync_folder( ).scalar_one_or_none() if existing_mail: + # Don't touch soft-deleted mails — they're being deleted via sync queue if existing_mail.deleted_at is not None: - existing_mail.deleted_at = None + continue continue # Fetch and parse the email @@ -1124,10 +1125,9 @@ async def imap_sync_account( ).scalar_one_or_none() if existing_mail: - # Restore soft-deleted mails if they still exist on IMAP + # Don't touch soft-deleted mails — they're being deleted via sync queue if existing_mail.deleted_at is not None: - existing_mail.deleted_at = None - logger.info("imap_sync: restored soft-deleted mail %s (still on IMAP)", existing_mail.id) + continue # Track folder moves: update folder_id and imap_uid if the # mail now appears in a different IMAP folder. if existing_mail.folder_id != folder.id: