Discard EnvelopeRename event if envelope is missing from Collection

async
Manos Pitsidianakis 2020-06-09 15:38:13 +03:00
parent f3d5edfe14
commit ca9d4fde58
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
2 changed files with 7 additions and 4 deletions

View File

@ -147,9 +147,9 @@ impl Collection {
old_hash: EnvelopeHash,
new_hash: EnvelopeHash,
mailbox_hash: MailboxHash,
) {
) -> bool {
if !self.envelopes.write().unwrap().contains_key(&old_hash) {
return;
return false;
}
let mut envelope = self.envelopes.write().unwrap().remove(&old_hash).unwrap();
self.mailboxes.entry(mailbox_hash).and_modify(|m| {
@ -168,7 +168,7 @@ impl Collection {
.update_envelope(&self.envelopes, old_hash, new_hash)
.is_ok()
{
return;
return true;
}
}
/* envelope is not in threads, so insert it */
@ -184,6 +184,7 @@ impl Collection {
.ok()
.take();
}
true
}
/// Merge new mailbox to collection and update threads.

View File

@ -535,7 +535,9 @@ impl Account {
}
RefreshEventKind::Rename(old_hash, new_hash) => {
debug!("rename {} to {}", old_hash, new_hash);
self.collection.rename(old_hash, new_hash, mailbox_hash);
if !self.collection.rename(old_hash, new_hash, mailbox_hash) {
return Some(EnvelopeRename(old_hash, new_hash));
}
#[cfg(feature = "sqlite3")]
{
let envelopes = self.collection.envelopes.read();