fix(autosave): autosave unsaved drawings + clean up .sv$ on file-close (#205)
Two gaps in the autosave recovery files: 1. A brand-new, never-saved drawing was never autosaved — on_autosave only wrote tabs that already had a path. A shared autosave_target() now writes saved drawings to <file>.sv$ and unsaved ones to the system temp dir (OpenCADStudio_<name>.sv$). 2. Closing a file (tab) left its .sv$ behind, which also defeated the program-close cleanup (it only scans still-open tabs). on_tab_close and the unsaved-discard path now delete the closing tab's .sv$, and Save/Save-As drop the temp copy a drawing used while it was still unsaved. Program-close cleanup (exit_app -> cleanup_autosaves) already worked. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
286caa9c61
commit
a9214db344
3 changed files with 39 additions and 13 deletions
|
|
@ -157,6 +157,9 @@ pub(super) fn on_ribbon_tool_click(&mut self, tool_id: String, event: ModuleEven
|
|||
match self.pending_close.take() {
|
||||
Some(crate::app::PendingClose::Tab(idx)) => {
|
||||
let close_win = self.close_unsaved_dialog_window();
|
||||
// Discarded — drop this tab's autosave recovery copy.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let _ = std::fs::remove_file(self.autosave_target(idx));
|
||||
if self.tabs.len() == 1 {
|
||||
self.tab_counter += 1;
|
||||
self.tabs[0] =
|
||||
|
|
@ -272,6 +275,8 @@ pub(super) fn on_ribbon_tool_click(&mut self, tool_id: String, event: ModuleEven
|
|||
Ok(()) => {
|
||||
self.command_line
|
||||
.push_output(&format!("Saved: {}", path.display()));
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let _ = std::fs::remove_file(self.autosave_target(idx));
|
||||
self.tabs[idx].current_path = Some(path);
|
||||
self.tabs[idx].dirty = false;
|
||||
return self.update(Message::TabClose(idx));
|
||||
|
|
@ -293,6 +298,8 @@ pub(super) fn on_ribbon_tool_click(&mut self, tool_id: String, event: ModuleEven
|
|||
Ok(()) => {
|
||||
self.command_line
|
||||
.push_output(&format!("Saved: {}", path.display()));
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let _ = std::fs::remove_file(self.autosave_target(i));
|
||||
self.tabs[i].current_path = Some(path);
|
||||
self.tabs[i].dirty = false;
|
||||
if self.tabs.iter().any(|t| t.dirty) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue