Describe the bug
When an IMAP server's UIDVALIDITY for a folder changes (rebuild, account migration, some Gmail label edits) every previously-cached UID is invalid. Today we don't read or persist UIDVALIDITY; the next fetch returns whatever new messages happen to live at our cached UIDs and the user sees ghost-message bodies for fresh mail.
Expected behavior
Persist UIDVALIDITY per folder. On every Select, compare; on change, drop the body cache for that folder and trigger a full re-list.
Why it's hard
UIDVALIDITY change is rare in practice — but when it happens, every downstream cache (folder cache, body cache, thread cache, search index) becomes garbage. Detecting and cascading the invalidation across all those layers is the work.
Describe the bug
When an IMAP server's
UIDVALIDITYfor a folder changes (rebuild, account migration, some Gmail label edits) every previously-cached UID is invalid. Today we don't read or persist UIDVALIDITY; the next fetch returns whatever new messages happen to live at our cached UIDs and the user sees ghost-message bodies for fresh mail.Expected behavior
Persist UIDVALIDITY per folder. On every Select, compare; on change, drop the body cache for that folder and trigger a full re-list.
Why it's hard
UIDVALIDITY change is rare in practice — but when it happens, every downstream cache (folder cache, body cache, thread cache, search index) becomes garbage. Detecting and cascading the invalidation across all those layers is the work.