diff --git a/crates/automation/src/headless.rs b/crates/automation/src/headless.rs index 8ec269bb4b1..a7193312765 100644 --- a/crates/automation/src/headless.rs +++ b/crates/automation/src/headless.rs @@ -345,9 +345,10 @@ impl Headless { let mut result = exported(dir, written, &mut outputs)?; if let Some(report) = report { let full = report.json(Vec::new()); - result["skipped"] = full["skipped"].clone(); - if let Some(stopped) = full.get("stopped") { - result["stopped"] = stopped.clone(); + for key in ["skipped", "stopped"] { + if let Some(value) = full.get(key) { + result[key] = value.clone(); + } } } Ok(result) diff --git a/crates/engine-core/src/cmd/variables_cmds.rs b/crates/engine-core/src/cmd/variables_cmds.rs index ee3059fa6b0..40f9019f1dd 100644 --- a/crates/engine-core/src/cmd/variables_cmds.rs +++ b/crates/engine-core/src/cmd/variables_cmds.rs @@ -465,7 +465,7 @@ fn split_csv(line: &str, delim: u8) -> Vec { } /// Apply each data set in turn and export the flattened document, restoring the original after. -/// `{dir, format?("png"), dataSets?[names], missingImage?, start?}` → `{files:[…],count,skipped,stopped?}`. +/// `{dir, format?("png"), dataSets?[names], missingImage?, start?}` → `{files:[…],count,skipped?,stopped?}`. fn export_as_files(s: &mut Session, p: &Value) -> Result { let dir = p.get("dir").and_then(Value::as_str).ok_or_else(|| bad("file.export.dataSetsAsFiles", "need `dir`"))?.to_string(); // The directory appears only once the batch has been planned, as it always did, so a batch @@ -518,7 +518,11 @@ impl DataSetsExportReport { /// The command's result, with `files` as the caller names them (joined to its folder). pub fn json(&self, files: Vec) -> Value { let count = files.len(); - let mut out = json!({"files": files, "count": count, "skipped": self.skipped}); + let mut out = json!({"files": files, "count": count}); + // Listed only when a set was left out, so an export without a missing image reads as before. + if !self.skipped.is_empty() { + out["skipped"] = json!(self.skipped); + } if let Some(stop) = &self.stopped { out["stopped"] = json!({"name": stop.name, "index": stop.index, "remaining": stop.remaining, "error": stop.error}); } @@ -693,7 +697,7 @@ pub fn specs() -> Vec { "file.export.dataSetsAsFiles", "Data Sets as Files…", &["File", "Export"], - "{dir, format?:png, dataSets?[names], naming?:\"{name}|{index}|{document}\", missingImage?:error|skip|stop, start?:n} → {files,count,skipped,stopped?:{name,index,remaining,error}}: apply each data set and export the flattened document; colliding filenames are rejected before writing (include {index} to disambiguate). A set whose Pixel Replacement image does not exist ends the export with an error (missingImage error, the default), is left out and listed in `skipped` (skip), or ends the export without an error, named in `stopped` (stop); `start` resumes at that 0-based set, keeping {index}", + "{dir, format?:png, dataSets?[names], naming?:\"{name}|{index}|{document}\", missingImage?:error|skip|stop, start?:n} → {files,count,skipped?,stopped?:{name,index,remaining,error}}: apply each data set and export the flattened document; colliding filenames are rejected before writing (include {index} to disambiguate). A set whose Pixel Replacement image does not exist ends the export with an error (missingImage error, the default), is left out and listed in `skipped` (skip), or ends the export without an error, named in `stopped` (stop); `start` resumes at that 0-based set, keeping {index}", has_data_sets, |s, p| export_as_files(s, p) ), diff --git a/crates/ui-egui/src/export_data_sets_missing_image_tests.rs b/crates/ui-egui/src/export_data_sets_missing_image_tests.rs index 9085ee0464a..f6078fd135f 100644 --- a/crates/ui-egui/src/export_data_sets_missing_image_tests.rs +++ b/crates/ui-egui/src/export_data_sets_missing_image_tests.rs @@ -167,7 +167,7 @@ fn the_command_reports_skipped_and_stopped_sets_without_a_prompt() { assert_eq!(r["stopped"]["index"], json!(1)); assert_eq!(r["stopped"]["remaining"], json!(1)); assert!(r["stopped"]["error"].as_str().unwrap().starts_with(photocraft_engine::DATA_SET_FILE_MISSING)); - assert_eq!(r["skipped"], json!([])); + assert!(r.get("skipped").is_none(), "nothing was skipped: {r}"); assert_eq!(files(&dir.join("stop")), ["001.png"]); // `start` resumes after the stop and keeps the numbering of the whole batch.