Plot style and plotter files save atomically through write_atomic (#1928 follow-up)

This commit is contained in:
MrBeeboh
2026-10-22 20:22:09 -07:00
parent a08fd7c1d1
commit 6ed822ec30
3 changed files with 30 additions and 6 deletions
+1 -3
View File
@@ -110,9 +110,7 @@ impl PlotterStore {
write: |n, t| {
let p = file(n)?;
std::fs::create_dir_all(dir()?).map_err(|e| e.to_string())?;
let tmp = p.with_extension("json.cadcraft-tmp");
std::fs::write(&tmp, t).map_err(|e| format!("{n}: {e}"))?;
std::fs::rename(&tmp, &p).map_err(|e| format!("{n}: {e}"))
crate::atomic_write::write_atomic(&p, t.as_bytes()).map_err(|e| format!("{n}: {e}"))
},
delete: |n| std::fs::remove_file(file(n)?).map_err(|e| format!("{n}: {e}")),
}