v0.9.3 — has:attachment without the minute-long scan
Performance follow-up to v0.9.2, which made has:attachment correct but slow — 34s on a 3000-message folder.
Measured against production rather than guessed: the IMAP searches are trivial (120ms to list all UIDs, 54ms for the multipart/ pre-filter). The entire cost is fetching bodyStructure, at roughly 23ms per message — over a minute for the whole folder.
The list view already fetches bodyStructure for every page it renders, so the answer is now recorded as it goes and the search only fetches messages nobody has looked at yet. In practice a browsed mailbox answers immediately. UIDs are immutable within a uidvalidity, so an entry never needs revisiting, and the flags are dropped alongside the rest of the folder cache on invalidation.
324 tests, 323 passing, 1 skipped.