mirror of
https://github.com/spartanz51/tutabridge.git
synced 2026-06-24 10:54:32 +02:00
Log the realtime delta path so it can be observed in the field
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 <source> → <target> (no REST)` — hit path, the mail was already cached in another folder. - `Event bus: targeted load_mail(...) → <target> (1 REST call)` — miss path, the mail had never been seen. - `Event bus: removed mail X from <source> (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.
This commit is contained in:
@@ -277,7 +277,11 @@ async fn apply_mail_set_entry_create(
|
|||||||
// HIT path: the mail already lives in another cached folder (typical
|
// HIT path: the mail already lives in another cached folder (typical
|
||||||
// MOVE between two known folders). Clone the StoredMail into the
|
// MOVE between two known folders). Clone the StoredMail into the
|
||||||
// target, allocate a fresh UID and persist.
|
// 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;
|
assign_uid_and_upsert(store, local_store, target_folder, &mail_eid, &mut stored).await;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -292,6 +296,10 @@ async fn apply_mail_set_entry_create(
|
|||||||
};
|
};
|
||||||
match backend.load_mail(&list_id, &mail_eid).await {
|
match backend.load_mail(&list_id, &mail_eid).await {
|
||||||
Ok(Some(mail)) => {
|
Ok(Some(mail)) => {
|
||||||
|
debug!(
|
||||||
|
"Event bus: targeted load_mail({}, {}) → {} (1 REST call)",
|
||||||
|
list_id, mail_eid, target_folder.imap_path
|
||||||
|
);
|
||||||
let mut stored = StoredMail {
|
let mut stored = StoredMail {
|
||||||
mail,
|
mail,
|
||||||
details: None,
|
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 {
|
let Some(source_folder) = folder_by_entries.get(ev.instance_list_id.as_str()).copied() else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
store
|
let removed = store
|
||||||
.remove_mail_from_folder(&source_folder.id, &mail_eid)
|
.remove_mail_from_folder(&source_folder.id, &mail_eid)
|
||||||
.await;
|
.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
|
// Drop the on-disk row + `.eml` only if no folder still holds the
|
||||||
// mail. Multi-folder placement (rare with the current Tuta model) and
|
// mail. Multi-folder placement (rare with the current Tuta model) and
|
||||||
// MOVE-within-batch (the matching CREATE ran first, so the target
|
// MOVE-within-batch (the matching CREATE ran first, so the target
|
||||||
|
|||||||
Reference in New Issue
Block a user