import review: refuse OK while a Lightroom import runs; set_transfer tolerates a short checked list (CodeRabbit on #2971)

This commit is contained in:
FredApps committed 2026-11-26 21:49:28 +07:00
1 parent f35bdd99b4
commit 27eda067f6
3 files changed
+26 -1

No files matched your search

+5 -1
View File
@@ -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;
}
}
}
}
@@ -204,6 +204,10 @@ impl ImportRun {
/// import runs: replacing `app.import` would stop its worker.
pub fn start(app: &mut LightcraftApp, d: &ImportDialog) -> Result<Value, String> {
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());
}
+17
View File
@@ -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]