mirror of
https://github.com/storytold/lightcraft.git
synced 2026-10-26 11:09:23 -06:00
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:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user