From f7db5043c5f8da139e3cd7979376cc5b091abc16 Mon Sep 17 00:00:00 2001 From: Leland Lucius Date: Sun, 5 Jul 2020 23:24:25 -0500 Subject: [PATCH] AUP3: UP-17 - Projects can be larger on UP-3.0.0 Partial relief only. This only addresses first symptom and it will needs to have a progress dialog added. --- src/ProjectFileIO.cpp | 54 ++++++++----------------------------------- src/ProjectFileIO.h | 1 - 2 files changed, 10 insertions(+), 45 deletions(-) diff --git a/src/ProjectFileIO.cpp b/src/ProjectFileIO.cpp index 71ad40d4d..2c385c56b 100644 --- a/src/ProjectFileIO.cpp +++ b/src/ProjectFileIO.cpp @@ -287,6 +287,15 @@ bool ProjectFileIO::CloseDB() if (mDB) { + if (!mTemporary) + { + rc = sqlite3_exec(mDB, "VACUUM;", nullptr, nullptr, nullptr); + if (rc != SQLITE_OK) + { + wxLogError(XO("Vacuuming failed while closing project file").Translation()); + } + } + rc = sqlite3_close(mDB); if (rc != SQLITE_OK) { @@ -321,50 +330,6 @@ bool ProjectFileIO::DeleteDB() return true; } -bool ProjectFileIO::CleanDB() -{ - auto db = DB(); - int rc; - - AutoSave(); - - wxString destpath = wxFileName::CreateTempFileName(mFileName + ".xxxxx"); - - if (CopyTo(destpath)) - { - if (CloseDB()) - { - wxString tmppath = wxFileName::CreateTempFileName(mFileName + ".xxxxx"); - if (wxRename(mFileName, tmppath) == 0) - { - if (wxRename(destpath, mFileName) == 0) - { - wxRemoveFile(tmppath); - - // Success - return true; - } - - if (wxRename(tmppath, mFileName) == 0) - { - wxRemoveFile(destpath); - } - else - { - SetError(XO("Could not rename %s back to %s during cleaning").Format(tmppath, mFileName)); - } - } - else - { - SetError(XO("Could not rename %s during cleaning").Format(mFileName)); - } - } - } - - // AUD3 TODO COMPILAIN - return false; -} - bool ProjectFileIO::TransactionStart(const wxString &name) { char* errmsg = nullptr; @@ -1259,6 +1224,7 @@ bool ProjectFileIO::SaveProject(const FilePath &fileName) // We need to remove the autosave info from the file since it is now // clean and unmodified. Otherwise, it would be considered "recovered" // when next opened. + AutoSaveDelete(); // No longer modified diff --git a/src/ProjectFileIO.h b/src/ProjectFileIO.h index 2634b508f..c34ffc7de 100644 --- a/src/ProjectFileIO.h +++ b/src/ProjectFileIO.h @@ -113,7 +113,6 @@ private: sqlite3 *OpenDB(FilePath fileName = {}); bool CloseDB(); bool DeleteDB(); - bool CleanDB(); bool TransactionStart(const wxString &name); bool TransactionCommit(const wxString &name);