From e3351d27555604524623bc8b6ae02f04a8414f97 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Mon, 1 Jan 2024 14:34:50 +0200 Subject: [PATCH] melib/imap: fix set unseen updating all mboxes When manually setting an envelope as not seen, all mailboxes had their unseen count increased. This commit updates only those that include the envelope in the first place. Signed-off-by: Manos Pitsidianakis --- melib/src/imap/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/melib/src/imap/mod.rs b/melib/src/imap/mod.rs index fbc65abd..21ae9efe 100644 --- a/melib/src/imap/mod.rs +++ b/melib/src/imap/mod.rs @@ -849,8 +849,8 @@ impl MailBackend for ImapType { .await?; if set_unseen { for f in uid_store.mailboxes.lock().await.values() { - if let Ok(mut unseen) = f.unseen.lock() { - for env_hash in env_hashes.iter() { + if let (Ok(mut unseen), Ok(exists)) = (f.unseen.lock(), f.exists.lock()) { + for env_hash in env_hashes.iter().filter(|h| exists.contains(h)) { unseen.insert_new(env_hash); } };