Files
tutabridge/crates
Anthony 407b31a622 feat(imap): on-demand body fetch correctness and anti-storm
needs_body() now triggers an on-demand fetch only for items that actually
need the body (BODY[] / BODY.PEEK[] / standalone RFC822). It used to fire for
ENVELOPE and every BODY[...] section, including BODY[HEADER...], so the
client's list-building did one full body+attachment download per message: on
a 19535-mail inbox that meant downloading the whole mailbox just to render
the list (the request storm, and an empty list while it ground on). Envelope,
header, size and structure items are answered from local metadata.

On a genuine fetch failure the bridge now returns a tagged NO [UNAVAILABLE]
instead of a successful response carrying a placeholder body (which made the
client cache a fake message and re-request forever). The failed mail is put
on a 30s cooldown, shared across IMAP connections via MailStore, so the
bridge does not re-hit a throttled server on every client redraw.

Tests: needs_body (skip metadata/header, trigger only on real body),
body-fetch cooldown set/expire.
2026-06-16 16:24:28 +02:00
..