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.
This commit is contained in:
Antonio Sokic
2026-10-30 20:26:34 +01:00
parent 052d95cd66
commit b9ba9d4640
2 changed files with 17 additions and 1 deletions
+10 -1
View File
@@ -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}");
}
l
+7
View File
@@ -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");