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
parent
8e036f045c
commit
ea0fb114e1
|
@ -164,7 +164,6 @@ pub struct UIDStore {
|
||||||
envelopes: Arc<Mutex<HashMap<EnvelopeHash, cache::CachedEnvelope>>>,
|
envelopes: Arc<Mutex<HashMap<EnvelopeHash, cache::CachedEnvelope>>>,
|
||||||
max_uids: Arc<Mutex<HashMap<MailboxHash, UID>>>,
|
max_uids: Arc<Mutex<HashMap<MailboxHash, UID>>>,
|
||||||
modseq: Arc<Mutex<HashMap<EnvelopeHash, ModSequence>>>,
|
modseq: Arc<Mutex<HashMap<EnvelopeHash, ModSequence>>>,
|
||||||
reverse_modseq: Arc<Mutex<HashMap<MailboxHash, BTreeMap<ModSequence, EnvelopeHash>>>>,
|
|
||||||
highestmodseqs: Arc<Mutex<HashMap<MailboxHash, std::result::Result<ModSequence, ()>>>>,
|
highestmodseqs: Arc<Mutex<HashMap<MailboxHash, std::result::Result<ModSequence, ()>>>>,
|
||||||
mailboxes: Arc<FutureMutex<HashMap<MailboxHash, ImapMailbox>>>,
|
mailboxes: Arc<FutureMutex<HashMap<MailboxHash, ImapMailbox>>>,
|
||||||
is_online: Arc<Mutex<(SystemTime, Result<()>)>>,
|
is_online: Arc<Mutex<(SystemTime, Result<()>)>>,
|
||||||
|
@ -188,7 +187,6 @@ impl UIDStore {
|
||||||
envelopes: Default::default(),
|
envelopes: Default::default(),
|
||||||
max_uids: Default::default(),
|
max_uids: Default::default(),
|
||||||
modseq: Default::default(),
|
modseq: Default::default(),
|
||||||
reverse_modseq: Default::default(),
|
|
||||||
highestmodseqs: Default::default(),
|
highestmodseqs: Default::default(),
|
||||||
hash_index: Default::default(),
|
hash_index: Default::default(),
|
||||||
uid_index: Default::default(),
|
uid_index: Default::default(),
|
||||||
|
|
|
@ -35,7 +35,7 @@ use std::convert::TryInto;
|
||||||
impl ImapConnection {
|
impl ImapConnection {
|
||||||
pub async fn process_untagged(&mut self, line: &[u8]) -> Result<bool> {
|
pub async fn process_untagged(&mut self, line: &[u8]) -> Result<bool> {
|
||||||
macro_rules! try_fail {
|
macro_rules! try_fail {
|
||||||
($mailbox_hash: expr, $($result:expr)+) => {
|
($mailbox_hash: expr, $($result:expr $(,)*)+) => {
|
||||||
$(if let Err(err) = $result {
|
$(if let Err(err) = $result {
|
||||||
self.uid_store.is_online.lock().unwrap().1 = Err(err.clone());
|
self.uid_store.is_online.lock().unwrap().1 = Err(err.clone());
|
||||||
debug!("failure: {}", err.to_string());
|
debug!("failure: {}", err.to_string());
|
||||||
|
@ -358,35 +358,17 @@ impl ImapConnection {
|
||||||
body: _,
|
body: _,
|
||||||
envelope: _,
|
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 {
|
if let Some(flags) = flags {
|
||||||
let uid = if let Some(uid) = uid {
|
let uid = if let Some(uid) = uid {
|
||||||
uid
|
uid
|
||||||
} else {
|
} else {
|
||||||
try_fail!(
|
try_fail!(
|
||||||
mailbox_hash,
|
mailbox_hash,
|
||||||
self.send_command(
|
self.send_command(format!("UID SEARCH {}", msg_seq).as_bytes())
|
||||||
&[
|
.await,
|
||||||
b"UID SEARCH",
|
self.read_response(&mut response, RequiredResponses::SEARCH)
|
||||||
format!("{}", msg_seq).as_bytes(),
|
.await,
|
||||||
]
|
);
|
||||||
.join(&b' '),
|
|
||||||
).await
|
|
||||||
self.read_response(&mut response, RequiredResponses::SEARCH).await
|
|
||||||
);
|
|
||||||
debug!(to_str!(&response));
|
debug!(to_str!(&response));
|
||||||
match super::protocol_parser::search_results(
|
match super::protocol_parser::search_results(
|
||||||
response.split_rn().next().unwrap_or(b""),
|
response.split_rn().next().unwrap_or(b""),
|
||||||
|
@ -398,8 +380,8 @@ impl ImapConnection {
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
debug!("SEARCH error failed: {}", e);
|
||||||
debug!(to_str!(&response));
|
debug!(to_str!(&response));
|
||||||
debug!(e);
|
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -419,13 +401,6 @@ impl ImapConnection {
|
||||||
mailbox.unseen.lock().unwrap().remove(env_hash);
|
mailbox.unseen.lock().unwrap().remove(env_hash);
|
||||||
}
|
}
|
||||||
if let Some(modseq) = modseq {
|
if let Some(modseq) = modseq {
|
||||||
self.uid_store
|
|
||||||
.reverse_modseq
|
|
||||||
.lock()
|
|
||||||
.unwrap()
|
|
||||||
.entry(mailbox_hash)
|
|
||||||
.or_default()
|
|
||||||
.insert(modseq, env_hash);
|
|
||||||
self.uid_store
|
self.uid_store
|
||||||
.modseq
|
.modseq
|
||||||
.lock()
|
.lock()
|
||||||
|
|
Loading…
Reference in New Issue