From bc03d244c617651e05bba291e40d790f6cfe4a00 Mon Sep 17 00:00:00 2001 From: Anthony Date: Wed, 27 May 2026 16:48:01 +0200 Subject: [PATCH] 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. --- crates/bridge/src/tuta.rs | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/crates/bridge/src/tuta.rs b/crates/bridge/src/tuta.rs index 9544ccb..af7798e 100644 --- a/crates/bridge/src/tuta.rs +++ b/crates/bridge/src/tuta.rs @@ -121,16 +121,22 @@ impl TutaSession { entries_list_id: &tutasdk::GeneratedId, limit: usize, ) -> Result, ApiCallError> { - let count = if limit == 0 { 1000 } else { limit }; - let entries: Vec = 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 = 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> =