From c6f11fb5927bb19a29b05434f0a733eee2c84c1e Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Wed, 26 Aug 2020 19:13:18 +0300 Subject: [PATCH] melib: update notify to 4.0.15 --- melib/Cargo.toml | 2 +- melib/src/backends.rs | 21 +++------------------ src/conf/accounts.rs | 19 +++++++++++++++++-- src/state.rs | 6 +++--- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/melib/Cargo.toml b/melib/Cargo.toml index bc2903bc..199f14c9 100644 --- a/melib/Cargo.toml +++ b/melib/Cargo.toml @@ -26,7 +26,7 @@ memmap = { version = "0.5.2", optional = true } nom = { version = "5.1.1" } indexmap = { version = "^1.5", features = ["serde-1", ] } -notify = { version = "4.0.1", optional = true } +notify = { version = "4.0.15", optional = true } xdg = "2.1.0" native-tls = { version ="0.2.3", optional=true } serde = { version = "1.0.71", features = ["rc", ] } diff --git a/melib/src/backends.rs b/melib/src/backends.rs index c4e7c354..5b240b8b 100644 --- a/melib/src/backends.rs +++ b/melib/src/backends.rs @@ -240,24 +240,9 @@ pub enum RefreshEventKind { #[derive(Debug, Clone)] pub struct RefreshEvent { - mailbox_hash: MailboxHash, - account_hash: AccountHash, - kind: RefreshEventKind, -} - -impl RefreshEvent { - pub fn mailbox_hash(&self) -> MailboxHash { - self.mailbox_hash - } - - pub fn account_hash(&self) -> AccountHash { - self.account_hash - } - - pub fn kind(self) -> RefreshEventKind { - /* consumes self! */ - self.kind - } + pub mailbox_hash: MailboxHash, + pub account_hash: AccountHash, + pub kind: RefreshEventKind, } #[derive(Clone)] diff --git a/src/conf/accounts.rs b/src/conf/accounts.rs index 576c08f2..02ef1225 100644 --- a/src/conf/accounts.rs +++ b/src/conf/accounts.rs @@ -599,11 +599,20 @@ impl Account { return None; } - let kind = event.kind(); { //let mailbox: &mut Mailbox = self.mailboxes[idx].as_mut().unwrap().as_mut().unwrap(); - match kind { + match event.kind { RefreshEventKind::Update(old_hash, envelope) => { + if !self.collection.contains_key(&old_hash) { + return self.reload( + RefreshEvent { + account_hash: event.account_hash, + mailbox_hash: event.mailbox_hash, + kind: RefreshEventKind::Create(envelope), + }, + mailbox_hash, + ); + } #[cfg(feature = "sqlite3")] { match crate::sqlite3::remove(old_hash).map(|_| { @@ -646,6 +655,9 @@ impl Account { return Some(EnvelopeUpdate(old_hash)); } RefreshEventKind::NewFlags(env_hash, (flags, tags)) => { + if !self.collection.contains_key(&env_hash) { + return None; + } self.collection .envelopes .write() @@ -833,6 +845,9 @@ impl Account { )); } RefreshEventKind::Remove(env_hash) => { + if !self.collection.contains_key(&env_hash) { + return None; + } let thread_hash = { let thread_hash = self.collection.get_env(env_hash).thread(); self.collection.get_threads(mailbox_hash).find_group( diff --git a/src/state.rs b/src/state.rs index 66a03c4d..93897bf8 100644 --- a/src/state.rs +++ b/src/state.rs @@ -386,8 +386,8 @@ impl State { * and startup a thread to remind us to poll it every now and then till it's finished. */ pub fn refresh_event(&mut self, event: RefreshEvent) { - let account_hash = event.account_hash(); - let mailbox_hash = event.mailbox_hash(); + let account_hash = event.account_hash; + let mailbox_hash = event.mailbox_hash; if self.context.accounts[&account_hash] .mailbox_entries .contains_key(&mailbox_hash) @@ -410,7 +410,7 @@ impl State { self.rcv_event(notification); } } else { - if let melib::backends::RefreshEventKind::Failure(err) = event.kind() { + if let melib::backends::RefreshEventKind::Failure(err) = event.kind { debug!(err); } }