From 56ced22c63b82a4a82bc9fb565a1250edbd29e47 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Wed, 24 Oct 2012 15:21:36 -0700 Subject: [PATCH] Mark autosave files with the current date and time This makes it so that autosave files are (almost) never overwritten, so that opening an old version of the file won't result in the autosaves from a newer version being replaced. Clean up old autosave files on startup to limit the total to 100 files/100 MB. Maybe make this configurable in the future? Closes #1155. --- aegisub/src/ass_file.cpp | 7 +++---- aegisub/src/main.cpp | 9 ++++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/aegisub/src/ass_file.cpp b/aegisub/src/ass_file.cpp index b58a2cdd3..266e6a636 100644 --- a/aegisub/src/ass_file.cpp +++ b/aegisub/src/ass_file.cpp @@ -164,10 +164,9 @@ wxString AssFile::AutoSave() { wxMkdir(path); wxString name = origfile.GetName(); - if (name.empty()) - dstpath.SetFullName("Untitled.AUTOSAVE.ass"); - else - dstpath.SetFullName(name + ".AUTOSAVE.ass"); + if (!name) + name = "Untitled"; + dstpath.SetFullName(wxString::Format("%s.%s.AUTOSAVE.ass", name, wxDateTime::Now().Format("%Y-%m-%d-%H-%M-%S"))); Save(dstpath.GetFullPath(), false, false); diff --git a/aegisub/src/main.cpp b/aegisub/src/main.cpp index 5ac03bb9a..445b319d1 100644 --- a/aegisub/src/main.cpp +++ b/aegisub/src/main.cpp @@ -282,15 +282,14 @@ bool AegisubApp::OnInit() { } #endif + StartupLog("Clean old autosave files"); + wxString autosave_path = lagi_wxString(OPT_GET("Path/Auto/Save")->GetString()); + CleanCache(autosave_path, "*.AUTOSAVE.ass", 100, 1000); + StartupLog("Initialization complete"); return true; } - - -/// @brief Exit -/// @return -/// int AegisubApp::OnExit() { if (frame) delete frame;