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

write_file_durable creates parent folders, which broke the ui-egui test
exporting_keywords_says_why_it_failed. Write atomically with
safe_file::write_atomic so a missing folder is still an error.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
GSibille
2026-10-19 15:16:15 +02:00
co-authored by Copilot App
parent b9640ef1d5
commit 3734c22fae
+3 -1
View File
@@ -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),