aboutsummaryrefslogtreecommitdiff
path: root/src/imap/index.rs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-01-08 21:18:45 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-01-08 21:18:45 +0100
commita90f425d32af866974eec58b43c02f302ae3376a (patch)
treedf05ec98cab270a236f75a3b9397af642492bcef /src/imap/index.rs
parentfe28120676b2de0adc5db52a5d437b956f88fc06 (diff)
downloadaerogramme-a90f425d32af866974eec58b43c02f302ae3376a.tar.gz
aerogramme-a90f425d32af866974eec58b43c02f302ae3376a.zip
Futures must be ordered
Diffstat (limited to 'src/imap/index.rs')
-rw-r--r--src/imap/index.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/imap/index.rs b/src/imap/index.rs
index f9228fe..4853374 100644
--- a/src/imap/index.rs
+++ b/src/imap/index.rs
@@ -104,16 +104,21 @@ impl<'a> Index<'a> {
return Ok(vec![]);
}
let iter_strat = sequence::Strategy::Naive {
- largest: self.last().expect("The mailbox is not empty").uid,
+ largest: NonZeroU32::try_from(self.imap_index.len() as u32)?,
};
- sequence_set
+ let mut acc = sequence_set
.iter(iter_strat)
.map(|wanted_id| {
self.imap_index
.get((wanted_id.get() as usize) - 1)
.ok_or(anyhow!("Mail not found"))
})
- .collect::<Result<Vec<_>>>()
+ .collect::<Result<Vec<_>>>()?;
+
+ // Sort the result to be consistent with UID
+ acc.sort_by(|a, b| a.i.cmp(&b.i));
+
+ Ok(acc)
}
pub fn fetch(