diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2020-09-20 13:29:57 +0300 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2020-09-20 13:29:57 +0300 |
commit | ea0fb114e15aa6a8fe905b1e50830fc36be1cb19 (patch) | |
tree | 5b60520276f4dcac8037d4c08a5b91556c77c14d /melib/src/backends | |
parent | 8e036f045c216afc0056ce3755987189c63d870c (diff) |
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.
Diffstat (limited to 'melib/src/backends')
-rw-r--r-- | melib/src/backends/imap.rs | 2 | ||||
-rw-r--r-- | melib/src/backends/imap/untagged.rs | 41 |
2 files changed, 8 insertions, 35 deletions
diff --git a/melib/src/backends/imap.rs b/melib/src/backends/imap.rs index beda1507..219946e4 100644 --- a/melib/src/backends/imap.rs +++ b/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(), diff --git a/melib/src/backends/imap/untagged.rs b/melib/src/backends/imap/untagged.rs index 52ba4930..021fa28b 100644 --- a/melib/src/backends/imap/untagged.rs +++ b/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); } } @@ -420,13 +402,6 @@ impl ImapConnection { } 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() .unwrap() |