mirror of
https://github.com/rustmailer/bichon.git
synced 2026-08-03 07:48:34 +02:00
When SMTP journaling ingests a message, parse_email() upserts the account's INBOX MailBox row so the journaled envelope has a row to attach to. But it built the row with uid_validity/highest_uid/uid_next = None and called batch_upsert, which replaces the WHOLE row. The INBOX row id (create_hash(account_id, "INBOX")) is the same id the IMAP sync maintains, so every journaled delivery reset the IMAP-maintained uid_validity to None. On the next reconcile, local_mailbox.uid_validity != Some(remote) is then true, so the mailbox is treated as invalid and wiped + rebuilt. For a large, UID-sparse INBOX whose rebuild gets interrupted, the local copy is silently lost and never restored (the incremental fetch resumes past all existing UIDs). See #297 for the full diagnosis and DB evidence. Fix: only create the INBOX row when it does not already exist; otherwise leave the IMAP-owned row untouched. The journaling path only needs the row to exist so the envelope can attach to it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>