From 4d1ec3333404de92be98f80239fc5175decc0d4b Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Mon, 8 Jan 2024 14:02:52 +0100 Subject: Make sure empty mailbox can be fetched/searched Required by a client (either GMail for Android, Outlook for iPhone, or Huawei Email) --- src/imap/index.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/imap/index.rs b/src/imap/index.rs index 3ca5562..fbd871a 100644 --- a/src/imap/index.rs +++ b/src/imap/index.rs @@ -1,6 +1,6 @@ use std::num::NonZeroU32; -use anyhow::{anyhow, Context, Result}; +use anyhow::{anyhow, Result}; use imap_codec::imap_types::sequence::{self, SeqOrUid, Sequence, SequenceSet}; use crate::mail::uidindex::{ImapUid, UidIndex}; @@ -80,10 +80,6 @@ impl<'a> Index<'a> { .partition_point(|mail_idx| &mail_idx.uid < start_seq); &self.imap_index[start_idx..] }; - println!( - "win: {:?}", - imap_idx.iter().map(|midx| midx.uid).collect::>() - ); let mut acc = vec![]; for wanted_uid in unroll_seq.iter() { @@ -104,8 +100,11 @@ impl<'a> Index<'a> { } pub fn fetch_on_id(&'a self, sequence_set: &SequenceSet) -> Result>> { + if self.imap_index.is_empty() { + return Ok(vec![]); + } let iter_strat = sequence::Strategy::Naive { - largest: self.last().context("The mailbox is empty")?.uid, + largest: self.last().expect("The mailbox is empty").uid, }; sequence_set .iter(iter_strat) -- cgit v1.2.3