Browse Source

melib/imap: delete reverse_modseq storage

Modsequences are not unique, and many messages may share the same
modsequence. So storing a reverse mapping of modsequences to messages is
invalid.
jmap-eventsource
Manos Pitsidianakis 1 year ago
parent
commit
ea0fb114e1
Signed by untrusted user: epilys GPG Key ID: 73627C2F690DF710
  1. 2
      melib/src/backends/imap.rs
  2. 41
      melib/src/backends/imap/untagged.rs

2
melib/src/backends/imap.rs

@ -164,7 +164,6 @@ pub struct UIDStore {
envelopes: Arc<Mutex<HashMap<EnvelopeHash, cache::CachedEnvelope>>>,
max_uids: Arc<Mutex<HashMap<MailboxHash, UID>>>,
modseq: Arc<Mutex<HashMap<EnvelopeHash, ModSequence>>>,
reverse_modseq: Arc<Mutex<HashMap<MailboxHash, BTreeMap<ModSequence, EnvelopeHash>>>>,
highestmodseqs: Arc<Mutex<HashMap<MailboxHash, std::result::Result<ModSequence, ()>>>>,
mailboxes: Arc<FutureMutex<HashMap<MailboxHash, ImapMailbox>>>,
is_online: Arc<Mutex<(SystemTime, Result<()>)>>,
@ -188,7 +187,6 @@ impl UIDStore {
envelopes: Default::default(),
max_uids: Default::default(),
modseq: Default::default(),
reverse_modseq: Default::default(),
highestmodseqs: Default::default(),
hash_index: Default::default(),
uid_index: Default::default(),

41
melib/src/backends/imap/untagged.rs

@ -35,7 +35,7 @@ use std::convert::TryInto;
impl ImapConnection {
pub async fn process_untagged(&mut self, line: &[u8]) -> Result<bool> {
macro_rules! try_fail {
($mailbox_hash: expr, $($result:expr)+) => {
($mailbox_hash: expr, $($result:expr $(,)*)+) => {
$(if let Err(err) = $result {
self.uid_store.is_online.lock().unwrap().1 = Err(err.clone());
debug!("failure: {}", err.to_string());
@ -358,35 +358,17 @@ impl ImapConnection {
body: _,
envelope: _,
}) => {
if let Some(modseq) = modseq {
if self
.uid_store
.reverse_modseq
.lock()
.unwrap()
.entry(mailbox_hash)
.or_default()
.contains_key(&modseq)
{
return Ok(true);
}
}
if let Some(flags) = flags {
let uid = if let Some(uid) = uid {
uid
} else {
try_fail!(
mailbox_hash,
self.send_command(
&[
b"UID SEARCH",
format!("{}", msg_seq).as_bytes(),
]
.join(&b' '),
).await
self.read_response(&mut response, RequiredResponses::SEARCH).await
);
mailbox_hash,
self.send_command(format!("UID SEARCH {}", msg_seq).as_bytes())
.await,
self.read_response(&mut response, RequiredResponses::SEARCH)
.await,
);
debug!(to_str!(&response));
match super::protocol_parser::search_results(
response.split_rn().next().unwrap_or(b""),
@ -398,8 +380,8 @@ impl ImapConnection {
return Ok(false);
}
Err(e) => {
debug!("SEARCH error failed: {}", e);
debug!(to_str!(&response));
debug!(e);
return Ok(false);
}
}
@ -419,13 +401,6 @@ impl ImapConnection {
mailbox.unseen.lock().unwrap().remove(env_hash);
}
if let Some(modseq) = modseq {
self.uid_store
.reverse_modseq
.lock()
.unwrap()
.entry(mailbox_hash)
.or_default()
.insert(modseq, env_hash);
self.uid_store
.modseq
.lock()

Loading…
Cancel
Save