mirror of
https://github.com/spartanz51/tutabridge.git
synced 2026-06-24 10:54:32 +02:00
`check_new_mail` only emitted `* N EXISTS` when the folder count changed. That misses a real-world case: a mail moved between two folders that share the same `sync_limit` window keeps the count constant (one mail in, one mail out) while swapping the set — so the IDLE'd Thunderbird session is never told and silently sticks to a stale view. Diff by element id instead. For every mail in `self.mails` whose id is no longer in the refreshed store, push an `* N EXPUNGE` (in descending seqno per RFC 3501 so subsequent values don't shift). Push one `EXISTS` afterwards with the new count; the client refetches and discovers any freshly added mail. Same-set updates stay quiet. 5 new tests cover the four shapes (no-op, growth, removal, swap with unchanged count) and the descending-EXPUNGE ordering.