LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
Issue #3406: tie the unreadable-folder note to the folder that failed
Antonio Sokicb9ba9d4640a1
diff --git a/crates/ui-egui/src/app/frame.rs b/crates/ui-egui/src/app/frame.rsindex 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<Vec<(String, u64)>, 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}");}ldiff --git a/crates/ui-egui/src/tests/drop_import.rs b/crates/ui-egui/src/tests/drop_import.rsindex 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");