LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
Merge remote-tracking branch 'upstream/main' into fix/strict-ids-params
Bruno-Alumnf32116bee1b0
diff --cc crates/ui-egui/src/control.rsindex ad2193daf,953874f6a..efb3ea3ac--- a/crates/ui-egui/src/control.rs+++ b/crates/ui-egui/src/control.rs@@@ -490,19 -484,10 +490,16 @@@ pub fn default_export_dir() -> Stringpub fn export_active(app: &mut LightcraftApp, p: &Value) -> Result<Value, String> {use lightcraft_engine::export::{Destination, ExportOptions, export_batch};let p = &app.session.export_params(p)?;- let mut opts = ExportOptions::from_params(p).map_err(|e| e.to_string())?;- if let (Some(path), None) = (p.get("path").and_then(Value::as_str), p.get("format")) {- let ext = path.rsplit_once('.').map_or("", |(_, e)| e);- opts.format = lightcraft_engine::export::ExportFormat::parse(ext).unwrap_or(opts.format);- }+ // the format follows `path` (JPEG when it names none), and `bitDepth` is checked against it+ let opts = ExportOptions::from_params(p).map_err(|e| e.to_string())?;- let ids: Vec<_> = match p.get("ids").and_then(Value::as_array) {- Some(a) => a.iter().filter_map(|v| serde_json::from_value(v.clone()).ok()).collect(),+ let ids: Vec<_> = match p.get("ids").filter(|v| !v.is_null()) {+ // `ids` that aren't photo ids are an error, not "export the selection"+ Some(v) => v+ .as_array()+ .ok_or("app.export: `ids` must be a list of photo ids")?+ .iter()+ .map(|v| v.as_u64().map(lightcraft_catalog::PhotoId).ok_or("app.export: `ids` must be photo ids (whole numbers)"))+ .collect::<Result<_, _>>()?,None if !app.session.selection.ids.is_empty() => {// Batch order (and `{seq}`) follows the grid order.let sel: std::collections::HashSet<_> = app.session.selection.ids.iter().copied().collect();