Skip to content

LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust

keyword.export: fail on a missing folder instead of creating it

GSibille3734c22fae03
diff --git a/crates/engine/src/cmd/keywords.rs b/crates/engine/src/cmd/keywords.rs
index 7858a19a8..676979c76 100644
--- a/crates/engine/src/cmd/keywords.rs
+++ b/crates/engine/src/cmd/keywords.rs
@@ -446,7 +446,9 @@ pub fn specs() -> Vec<CommandSpec> {
match str_param(p, "path").map(str::trim).filter(|x| !x.is_empty()) {
Some(path) => {
s.check_write_target(path).map_err(|e| bad("keyword.export", e))?;
- crate::export::write_file_durable(path, file.text.as_bytes()).map_err(crate::EngineError::Other)?;
+ // A folder that isn't there is an error, not created.
+ lightcraft_catalog::safe_file::write_atomic(std::path::Path::new(path), file.text.as_bytes())
+ .map_err(|e| crate::EngineError::Other(format!("{path}: {e}")))?;
r["path"] = json!(path);
}
None => r["text"] = json!(file.text),