Fetch the whole folder when sync_limit is 0 ("all")

Previously sync_limit=0 still loaded a single 1000-entry page, so the
mailbox was effectively capped. Use the SDK's paginated load_all to walk
the entire MailSetEntry list when the limit is 0, keeping a single capped
load_range for a finite limit.

Live-tested: with sync_limit=0, INBOX loads all 19288 mails (was capped
at 500) with stable UIDs 1..19288.
This commit is contained in:
Anthony
2026-05-27 16:53:00 +02:00
committed by Anthony M
parent 578a8357b6
commit bc03d244c6
+16 -10
View File
@@ -121,16 +121,22 @@ impl TutaSession {
entries_list_id: &tutasdk::GeneratedId,
limit: usize,
) -> Result<Vec<Mail>, ApiCallError> {
let count = if limit == 0 { 1000 } else { limit };
let entries: Vec<MailSetEntry> = self
.crypto_client()
.load_range(
entries_list_id,
&CustomId::default(),
count,
ListLoadDirection::DESC,
)
.await?;
// limit == 0 means "all": paginate the whole entries list. Otherwise
// load a single capped page (newest first).
let entries: Vec<MailSetEntry> = if limit == 0 {
self.crypto_client()
.load_all(entries_list_id, ListLoadDirection::DESC)
.await?
} else {
self.crypto_client()
.load_range(
entries_list_id,
&CustomId::default(),
limit,
ListLoadDirection::DESC,
)
.await?
};
// Group entries by list_id for batch loading
let mut by_list: std::collections::HashMap<String, Vec<tutasdk::GeneratedId>> =