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:48:01 +02:00
parent a65e36d514
commit 87e03c6035
+16 -10
View File
@@ -121,16 +121,22 @@ impl TutaSession {
entries_list_id: &tutasdk::GeneratedId, entries_list_id: &tutasdk::GeneratedId,
limit: usize, limit: usize,
) -> Result<Vec<Mail>, ApiCallError> { ) -> Result<Vec<Mail>, ApiCallError> {
let count = if limit == 0 { 1000 } else { limit }; // limit == 0 means "all": paginate the whole entries list. Otherwise
let entries: Vec<MailSetEntry> = self // load a single capped page (newest first).
.crypto_client() let entries: Vec<MailSetEntry> = if limit == 0 {
.load_range( self.crypto_client()
entries_list_id, .load_all(entries_list_id, ListLoadDirection::DESC)
&CustomId::default(), .await?
count, } else {
ListLoadDirection::DESC, self.crypto_client()
) .load_range(
.await?; entries_list_id,
&CustomId::default(),
limit,
ListLoadDirection::DESC,
)
.await?
};
// Group entries by list_id for batch loading // Group entries by list_id for batch loading
let mut by_list: std::collections::HashMap<String, Vec<tutasdk::GeneratedId>> = let mut by_list: std::collections::HashMap<String, Vec<tutasdk::GeneratedId>> =