From d31bd49165f6a42ec4cf54a4c5e30fc7355b60a1 Mon Sep 17 00:00:00 2001 From: Anthony Date: Thu, 28 May 2026 14:41:11 +0200 Subject: [PATCH] Log the realtime delta path so it can be observed in the field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The new MailSetEntry CREATE/DELETE path applies changes silently to MailStore + LocalStore; debug logs make it visible in the dev log so we (and users running with RUST_LOG=debug) can confirm which path was taken on a given event: - `Event bus: cloning mail X from (no REST)` — hit path, the mail was already cached in another folder. - `Event bus: targeted load_mail(...) → (1 REST call)` — miss path, the mail had never been seen. - `Event bus: removed mail X from (no REST)` — DELETE applied without re-listing. Live-tested: a TB-initiated MOVE between two cached folders now logs the cloning + removed lines and zero `Pre-fetching` / `Removed N deleted` lines for the affected folders, confirming we no longer touch the REST API for that case. --- crates/bridge/src/event_handler.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/crates/bridge/src/event_handler.rs b/crates/bridge/src/event_handler.rs index 391075d..f0fbea1 100644 --- a/crates/bridge/src/event_handler.rs +++ b/crates/bridge/src/event_handler.rs @@ -277,7 +277,11 @@ async fn apply_mail_set_entry_create( // HIT path: the mail already lives in another cached folder (typical // MOVE between two known folders). Clone the StoredMail into the // target, allocate a fresh UID and persist. - if let Some((_source_folder, mut stored)) = store.find_mail_anywhere(&mail_eid).await { + if let Some((source_folder, mut stored)) = store.find_mail_anywhere(&mail_eid).await { + debug!( + "Event bus: cloning mail {} from {} → {} (no REST)", + mail_eid, source_folder, target_folder.imap_path + ); assign_uid_and_upsert(store, local_store, target_folder, &mail_eid, &mut stored).await; return; } @@ -292,6 +296,10 @@ async fn apply_mail_set_entry_create( }; match backend.load_mail(&list_id, &mail_eid).await { Ok(Some(mail)) => { + debug!( + "Event bus: targeted load_mail({}, {}) → {} (1 REST call)", + list_id, mail_eid, target_folder.imap_path + ); let mut stored = StoredMail { mail, details: None, @@ -337,9 +345,15 @@ async fn apply_mail_set_entry_delete( let Some(source_folder) = folder_by_entries.get(ev.instance_list_id.as_str()).copied() else { return; }; - store + let removed = store .remove_mail_from_folder(&source_folder.id, &mail_eid) .await; + if removed { + debug!( + "Event bus: removed mail {} from {} (no REST)", + mail_eid, source_folder.imap_path + ); + } // Drop the on-disk row + `.eml` only if no folder still holds the // mail. Multi-folder placement (rare with the current Tuta model) and // MOVE-within-batch (the matching CREATE ran first, so the target