From b9ba9d4640a15dde83eb18633b9e90ba53f44bfe Mon Sep 17 00:00:00 2001 From: Antonio Sokic <5701985+finaler1x@users.noreply.github.com> Date: Fri, 30 Oct 2026 20:26:34 +0100 Subject: [PATCH] Issue #3406: tie the unreadable-folder note to the folder that failed The note now goes when another folder is watched, a listing of a folder no longer watched is ignored, and "can be read again" is logged only for the folder that failed. --- crates/ui-egui/src/app/frame.rs | 11 ++++++++++- crates/ui-egui/src/tests/drop_import.rs | 7 +++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/app/frame.rs b/crates/ui-egui/src/app/frame.rs index 995796bd4..08c5bfee9 100644 --- a/crates/ui-egui/src/app/frame.rs +++ b/crates/ui-egui/src/app/frame.rs @@ -81,6 +81,10 @@ impl LightcraftApp { focus_scan::pump(self, ctx, now); // auto import: list the watched folder every few seconds (on a worker thread: it may be on // a network share), then import what's new like any import (also on a worker thread) + // a folder that couldn't be read stops being one once another is watched (or none) + if self.ui.auto_import_error.as_ref().is_some_and(|(f, _)| self.session.import_defaults.auto_folder.as_ref() != Some(f)) { + self.ui.auto_import_error = None; + } #[cfg(not(target_arch = "wasm32"))] if let Some(folder) = self.session.import_defaults.auto_folder.clone() { const LABEL: &str = "Auto Import"; @@ -94,9 +98,14 @@ impl LightcraftApp { let listed = folder.clone(); let work = move || lightcraft_engine::cmd::library::list_auto_import_folder(&listed); let done = move |app: &mut LightcraftApp, _ctx: &egui::Context, listing: Result, String>| { + // the watched folder changed while this one was listed: its result is for nothing on screen + if app.session.import_defaults.auto_folder.as_ref() != Some(&folder) { + return; + } let listing = match listing { Ok(l) => { - if app.ui.auto_import_error.take().is_some() { + if app.ui.auto_import_error.as_ref().is_some_and(|(f, _)| *f == folder) { + app.ui.auto_import_error = None; log::info!("auto import: the watched folder can be read again: {folder}"); } l diff --git a/crates/ui-egui/src/tests/drop_import.rs b/crates/ui-egui/src/tests/drop_import.rs index ced30ddc1..c380b7774 100644 --- a/crates/ui-egui/src/tests/drop_import.rs +++ b/crates/ui-egui/src/tests/drop_import.rs @@ -1120,6 +1120,13 @@ fn auto_import_notes_a_watched_folder_it_cannot_read() { let (folder, e) = h.app.ui.auto_import_error.clone().unwrap(); assert_eq!(folder, watch); assert!(e.starts_with(&watch) && e.len() > watch.len() + 2, "the error says why: {e}"); + // another folder watched: the note was about the old one, so it goes, and a listing of the old one + // still under way doesn't bring it back + h.app.session.import_defaults.auto_folder = Some(dir.path("trip")); + h.step(); + assert!(h.app.ui.auto_import_error.is_none(), "{:?}", h.app.ui.auto_import_error); + h.app.session.import_defaults.auto_folder = Some(watch.clone()); + assert!(h.step_until(T, |h| h.app.ui.auto_import_error.is_some()), "back to the missing folder: noted again"); write_png(&dir.path("watch/w.png"), 3); assert!(h.step_until(T, |h| h.app.ui.auto_import_error.is_none()), "readable again: the note goes"); assert!(h.step_until(T, |h| photos(h) == 1), "and the photo arrives");