Anthony 578a8357b6 Persist stable IMAP UIDs across restarts
UIDs were assigned from an in-memory counter that reset to 1 on every
bridge restart, so the UID<->mail mapping changed each run and IMAP
clients (Thunderbird) re-downloaded the whole mailbox on reconnect.

Persist a per-folder monotonic UID in the local store (schema v3):
- mails gain a `uid` column; sync_state gains a `next_uid` counter that
  only ever advances (UIDs are never reused).
- The syncer keeps each mail's existing UID and allocates new ones for
  new mail (oldest-first, so newer mail gets higher UIDs).
- refresh_mails uses the persisted UID instead of allocating; messages
  are ordered by UID. UIDVALIDITY stays constant.

Migration v2->v3 drops the cache tables and re-syncs once (encrypted
.eml files survive). Live-tested: UID<->mail mapping is identical before
and after a restart (range 1..500 unchanged), so clients fetch only the
delta instead of re-downloading.
2026-05-27 16:43:44 +02:00
2026-05-27 16:05:11 +02:00
Languages
Rust 89.5%
TypeScript 5.9%
CSS 2.5%
Python 1.2%
Shell 0.7%
Other 0.1%