melib/imap: don't clear mailbox counts before fetching
parent
5f6b4745b8
commit
8e7583a32f
|
@ -647,15 +647,10 @@ impl LazyCountSet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn insert_existing_set(&mut self, set: BTreeSet<EnvelopeHash>) -> bool {
|
pub fn insert_existing_set(&mut self, set: BTreeSet<EnvelopeHash>) {
|
||||||
if self.not_yet_seen < set.len() {
|
let old_len = self.set.len();
|
||||||
false
|
self.set.extend(set.into_iter());
|
||||||
} else {
|
self.not_yet_seen = self.not_yet_seen.saturating_sub(self.set.len() - old_len);
|
||||||
let old_len = self.set.len();
|
|
||||||
self.set.extend(set.into_iter());
|
|
||||||
self.not_yet_seen -= self.set.len() - old_len;
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
|
|
@ -343,12 +343,24 @@ impl MailBackend for ImapType {
|
||||||
cache_handle,
|
cache_handle,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* do this in a closure to prevent recursion limit error in async_stream macro */
|
||||||
|
let prepare_cl = |f: &ImapMailbox| {
|
||||||
|
f.set_warm(true);
|
||||||
|
if let Ok(mut exists) = f.exists.lock() {
|
||||||
|
let total = exists.len();
|
||||||
|
exists.clear();
|
||||||
|
exists.set_not_yet_seen(total);
|
||||||
|
}
|
||||||
|
if let Ok(mut unseen) = f.unseen.lock() {
|
||||||
|
let total = unseen.len();
|
||||||
|
unseen.clear();
|
||||||
|
unseen.set_not_yet_seen(total);
|
||||||
|
}
|
||||||
|
};
|
||||||
Ok(Box::pin(async_stream::try_stream! {
|
Ok(Box::pin(async_stream::try_stream! {
|
||||||
{
|
{
|
||||||
let f = &state.uid_store.mailboxes.lock().await[&mailbox_hash];
|
let f = &state.uid_store.mailboxes.lock().await[&mailbox_hash];
|
||||||
f.exists.lock().unwrap().clear();
|
prepare_cl(f);
|
||||||
f.unseen.lock().unwrap().clear();
|
|
||||||
f.set_warm(true);
|
|
||||||
if f.no_select {
|
if f.no_select {
|
||||||
yield vec![];
|
yield vec![];
|
||||||
return;
|
return;
|
||||||
|
@ -1629,7 +1641,7 @@ async fn fetch_hlpr(state: &mut FetchState) -> Result<Vec<Envelope>> {
|
||||||
let f = &state.uid_store.mailboxes.lock().await[&state.mailbox_hash];
|
let f = &state.uid_store.mailboxes.lock().await[&state.mailbox_hash];
|
||||||
(f.exists.clone(), f.unseen.clone())
|
(f.exists.clone(), f.unseen.clone())
|
||||||
};
|
};
|
||||||
unseen.lock().unwrap().insert_set(
|
unseen.lock().unwrap().insert_existing_set(
|
||||||
cached_payload
|
cached_payload
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|env| {
|
.filter_map(|env| {
|
||||||
|
@ -1641,10 +1653,9 @@ async fn fetch_hlpr(state: &mut FetchState) -> Result<Vec<Envelope>> {
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
);
|
);
|
||||||
mailbox_exists
|
mailbox_exists.lock().unwrap().insert_existing_set(
|
||||||
.lock()
|
cached_payload.iter().map(|env| env.hash()).collect::<_>(),
|
||||||
.unwrap()
|
);
|
||||||
.insert_set(cached_payload.iter().map(|env| env.hash()).collect::<_>());
|
|
||||||
return Ok(cached_payload);
|
return Ok(cached_payload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue