fix: stop restoring soft-deleted mails during sync — they stay deleted
- 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
This commit is contained in:
@@ -636,8 +636,9 @@ async def imap_sync_folder(
|
|||||||
).scalar_one_or_none()
|
).scalar_one_or_none()
|
||||||
|
|
||||||
if existing_mail:
|
if existing_mail:
|
||||||
|
# Don't touch soft-deleted mails — they're being deleted via sync queue
|
||||||
if existing_mail.deleted_at is not None:
|
if existing_mail.deleted_at is not None:
|
||||||
existing_mail.deleted_at = None
|
continue
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Fetch and parse the email
|
# Fetch and parse the email
|
||||||
@@ -1124,10 +1125,9 @@ async def imap_sync_account(
|
|||||||
).scalar_one_or_none()
|
).scalar_one_or_none()
|
||||||
|
|
||||||
if existing_mail:
|
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:
|
if existing_mail.deleted_at is not None:
|
||||||
existing_mail.deleted_at = None
|
continue
|
||||||
logger.info("imap_sync: restored soft-deleted mail %s (still on IMAP)", existing_mail.id)
|
|
||||||
# Track folder moves: update folder_id and imap_uid if the
|
# Track folder moves: update folder_id and imap_uid if the
|
||||||
# mail now appears in a different IMAP folder.
|
# mail now appears in a different IMAP folder.
|
||||||
if existing_mail.folder_id != folder.id:
|
if existing_mail.folder_id != folder.id:
|
||||||
|
|||||||
Reference in New Issue
Block a user