Default fetch all mail #12

Closed
opened 2026-07-01 03:05:52 +00:00 by JMR-dev · 0 comments
JMR-dev commented 2026-07-01 03:05:52 +00:00 (Migrated from github.com)

Context

Today header sync is capped at the 50 most recent messages per folder
(MailSyncer.FETCH_LIMIT = 50); the existing FetchPolicy governs body/attachment prefetch,
not history depth. Per decision, the default becomes fetching the entire mailbox history.

Scope

  • Replace the fixed 50-header cap with a full-history sync: page backwards through each
    folder (batched IMAP fetch) until the whole folder is cached.
  • Run the backfill in the background (WorkManager) — resumable and cancellable — without
    blocking foreground sync / pull-to-refresh; track per-folder progress (e.g. lowest UID
    fetched).
  • Keep respecting FetchPolicy for body/attachment prefetch (headers first; bodies per
    policy).
  • Batch + back off to avoid hammering the server or exhausting memory on large mailboxes;
    surface progress in the UI.
  • Applies to new and existing accounts; retention (#13) is the escape valve.

Acceptance criteria

  • A new account backfills its full history over time, not just 50 messages.
  • Backfill survives process death / network loss and resumes; foreground UX stays responsive.

Relevant files

  • data/sync/MailSyncer.kt (FETCH_LIMIT, paging), mail/ImapClient.kt (fetchRecent -> paged),
    sync workers/scheduler, a DAO for backfill progress

Dependencies

Pairs with #13 (retention bounds what's kept). Larger cache affects #21 (backup size)
and #22 (encrypted cache).

## Context Today header sync is capped at the 50 most recent messages per folder (`MailSyncer.FETCH_LIMIT = 50`); the existing `FetchPolicy` governs body/attachment prefetch, not history depth. Per decision, the default becomes fetching the **entire** mailbox history. ## Scope - [ ] Replace the fixed 50-header cap with a full-history sync: page backwards through each folder (batched IMAP fetch) until the whole folder is cached. - [ ] Run the backfill in the background (WorkManager) — resumable and cancellable — without blocking foreground sync / pull-to-refresh; track per-folder progress (e.g. lowest UID fetched). - [ ] Keep respecting `FetchPolicy` for body/attachment prefetch (headers first; bodies per policy). - [ ] Batch + back off to avoid hammering the server or exhausting memory on large mailboxes; surface progress in the UI. - [ ] Applies to new and existing accounts; retention (#13) is the escape valve. ## Acceptance criteria - A new account backfills its full history over time, not just 50 messages. - Backfill survives process death / network loss and resumes; foreground UX stays responsive. ## Relevant files - `data/sync/MailSyncer.kt` (FETCH_LIMIT, paging), `mail/ImapClient.kt` (`fetchRecent` -> paged), sync workers/scheduler, a DAO for backfill progress ## Dependencies Pairs with **#13** (retention bounds what's kept). Larger cache affects **#21** (backup size) and **#22** (encrypted cache).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: JMR-dev/LibreMail#12