fix(io): guard concurrent drawing saves

Hold edit leases and compare disk fingerprints before replacement so another editor cannot be silently overwritten.

Offer retry, reload, Save As, or explicit overwrite recovery.

Closes #498
This commit is contained in:
Hakan Seven 2026-07-27 13:13:58 +03:00
commit 2acc4f7978
12 changed files with 1424 additions and 23 deletions

View file

@ -350,9 +350,14 @@ impl OpenCADStudio {
let Some(path) = path else {
return err("save: no \"path\" and the document has none");
};
match crate::io::save(&self.tabs[i].scene.document, &path) {
#[cfg(not(target_arch = "wasm32"))]
let result =
self.save_tab_synchronously_protected(i, path.clone(), true);
#[cfg(target_arch = "wasm32")]
let result = crate::io::save(&self.tabs[i].scene.document, &path)
.map_err(crate::io::SaveFailure::other);
match result {
Ok(()) => {
self.tabs[i].current_path = Some(path.clone());
json!({ "ok": true, "saved": path.to_string_lossy() })
}
Err(e) => err(format!("save: {e}")),