mirror of
https://github.com/spartanz51/tutabridge.git
synced 2026-06-24 10:54:32 +02:00
When a brand-new mail lands through the realtime event bus, its attached `File` entities are queryable on the server but the encryption metadata (`_ownerEncSessionKey` / `_ownerGroup`) may not have propagated yet — `CryptoEntityClient::load` then returns 'instance missing owner key/group data' a few seconds before the same load would succeed. The previous code surfaced that as a permanent attachment-load failure inside `prefetch_details` (best-effort fallback to a body-only multipart), so a PDF sent via SMTP appeared body-only in Thunderbird and only recovered after a manual sync. Add `load_file_with_retry` in `TutaSession`: when `is_session_key_transient(e)` (matching on the SDK error message), back off 1s / 3s / 6s before retrying, then bubble up so the existing ship-body-only fallback still applies. \~10s of tolerance is enough in practice while staying well under the SMTP/IMAP latency budget. Four unit tests cover the helper: matches the exact 'missing owner key/group data' wording, the generic 'Session key resolution failure' prefix, rejects unrelated SDK errors, accepts a bare 'missing owner key/group data' message (paranoid catch).