diff --git a/crates/ui-egui/src/dialogs/import.rs b/crates/ui-egui/src/dialogs/import.rs index ea4b27cd1a..86dc4e01eb 100644 --- a/crates/ui-egui/src/dialogs/import.rs +++ b/crates/ui-egui/src/dialogs/import.rs @@ -183,7 +183,11 @@ impl ImportDialog { self.move_files = copy && move_files; for i in (0..self.candidates.len()).filter(|_| switched) { if self.candidates[i].browsed_twin.is_some() && !self.candidates[i].local { - self.checked[i] = self.is_copy_twin(i); + // (a dialog read back may hold fewer check marks than candidates) + let twin = self.is_copy_twin(i); + if let Some(checked) = self.checked.get_mut(i) { + *checked = twin; + } } } } diff --git a/crates/ui-egui/src/dialogs/import/task.rs b/crates/ui-egui/src/dialogs/import/task.rs index 18179685f3..c0fcabdc26 100644 --- a/crates/ui-egui/src/dialogs/import/task.rs +++ b/crates/ui-egui/src/dialogs/import/task.rs @@ -204,6 +204,10 @@ impl ImportRun { /// import runs: replacing `app.import` would stop its worker. pub fn start(app: &mut LightcraftApp, d: &ImportDialog) -> Result { busy_synchronizing(app)?; + // a Lightroom catalog import owns the catalog until it ends (its photos may share a file's content), as for a drop + if app.lightroom.is_some() { + return Err(crate::i18n::tr("Finish Lightroom catalog import before adding photos").to_string()); + } if !d.in_library(app) { return Err("another library was opened since the photos were scanned: nothing was imported".into()); } diff --git a/crates/ui-egui/src/tests/drop_import.rs b/crates/ui-egui/src/tests/drop_import.rs index 7dffeb491c..1a8e83f7fd 100644 --- a/crates/ui-egui/src/tests/drop_import.rs +++ b/crates/ui-egui/src/tests/drop_import.rs @@ -657,6 +657,23 @@ fn a_queued_drop_waits_for_a_running_lightroom_import_instead_of_being_refused() ); } +/// The review's OK is refused while a Lightroom catalog import owns the catalog, as a drop is: nothing is imported +/// beside it (CodeRabbit on #2971). +#[test] +fn an_import_review_is_not_confirmed_while_a_lightroom_import_runs() { + let dir = Scratch::new("review-lightroom"); + let mut h = app_with_library(&dir); + h.app.ui.settings.import_dropped_directly = false; + drop_files(&mut h, &[dir.path("trip/a.png")], false); + assert!(h.step_until(SETTLE, |h| matches!(h.app.ui.dialog, Some(Dialog::Import { .. }))), "the review opens"); + let task = crate::lightroom_import::stall_import(&mut h.app); + let reply = h.request("ui.dialog.confirm", json!({}), T); + assert_ne!(reply["ok"], true, "{reply}"); + assert!(h.app.import.is_none(), "no import started"); + assert_eq!(photos(&h), 0); + drop(task); +} + /// Cancelling Open Another…'s asynchronous picker keeps the launch list up; the queued photo is /// then held for the library chosen rather than dropped behind the cancelling picker. #[test]