mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-25 08:58:06 +02:00
Bug2599: -wal and -shm of discarded temp projects should clean up
This commit is contained in:
parent
0d5b9753bc
commit
7e1e339f72
@ -287,25 +287,7 @@ void AutoRecoveryDialog::OnDiscardSelected(wxCommandEvent &WXUNUSED(evt))
|
|||||||
|
|
||||||
wxFileName temp(FileNames::TempDir(), wxT(""));
|
wxFileName temp(FileNames::TempDir(), wxT(""));
|
||||||
if (file == temp)
|
if (file == temp)
|
||||||
{
|
ProjectFileIO::RemoveProject(fileName);
|
||||||
if (wxRemoveFile(fileName))
|
|
||||||
{
|
|
||||||
if (wxFileExists(fileName + wxT("-shm")))
|
|
||||||
{
|
|
||||||
wxRemoveFile(fileName + wxT("-shm"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wxFileExists(fileName + wxT("-wal")))
|
|
||||||
{
|
|
||||||
wxRemoveFile(fileName + wxT("-wal"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wxFileExists(fileName + wxT("-journal")))
|
|
||||||
{
|
|
||||||
wxRemoveFile(fileName + wxT("-journal"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
// Don't remove from disk, but do (later) open the database
|
// Don't remove from disk, but do (later) open the database
|
||||||
|
@ -392,9 +392,7 @@ void ProjectFileIO::DiscardConnection()
|
|||||||
wxFileName file(mPrevFileName);
|
wxFileName file(mPrevFileName);
|
||||||
file.SetFullName(wxT(""));
|
file.SetFullName(wxT(""));
|
||||||
if (file == temp)
|
if (file == temp)
|
||||||
{
|
RemoveProject(mPrevFileName);
|
||||||
wxRemoveFile(mPrevFileName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
mPrevConn = nullptr;
|
mPrevConn = nullptr;
|
||||||
mPrevFileName.clear();
|
mPrevFileName.clear();
|
||||||
@ -742,6 +740,7 @@ bool ProjectFileIO::CopyTo(const FilePath &destpath,
|
|||||||
|
|
||||||
sqlite3_exec(db, "DETACH DATABASE outbound;", nullptr, nullptr, nullptr);
|
sqlite3_exec(db, "DETACH DATABASE outbound;", nullptr, nullptr, nullptr);
|
||||||
|
|
||||||
|
// RemoveProject not necessary to clean up attached database
|
||||||
wxRemoveFile(destpath);
|
wxRemoveFile(destpath);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1051,6 +1050,21 @@ bool ProjectFileIO::MoveProject(const FilePath &src, const FilePath &dst)
|
|||||||
return (success = true);
|
return (success = true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ProjectFileIO::RemoveProject(const FilePath &filename)
|
||||||
|
{
|
||||||
|
if (!wxFileExists(filename))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bool success = wxRemoveFile(filename);
|
||||||
|
auto &suffixes = AuxiliaryFileSuffixes();
|
||||||
|
for (const auto &suffix : suffixes) {
|
||||||
|
auto file = filename + suffix;
|
||||||
|
if (wxFileExists(file))
|
||||||
|
success = wxRemoveFile(file) && success;
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
ProjectFileIO::BackupProject::BackupProject(
|
ProjectFileIO::BackupProject::BackupProject(
|
||||||
ProjectFileIO &projectFileIO, const FilePath &path )
|
ProjectFileIO &projectFileIO, const FilePath &path )
|
||||||
{
|
{
|
||||||
@ -1066,13 +1080,7 @@ void ProjectFileIO::BackupProject::Discard()
|
|||||||
{
|
{
|
||||||
if (!mPath.empty()) {
|
if (!mPath.empty()) {
|
||||||
// Succeeded; don't need the safety files
|
// Succeeded; don't need the safety files
|
||||||
auto suffixes = AuxiliaryFileSuffixes();
|
RemoveProject(mSafety);
|
||||||
suffixes.push_back({});
|
|
||||||
for (const auto &suffix : suffixes) {
|
|
||||||
auto path = mSafety + suffix;
|
|
||||||
if (wxFileExists(path))
|
|
||||||
wxRemoveFile(path);
|
|
||||||
}
|
|
||||||
mSafety.clear();
|
mSafety.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1171,6 +1179,8 @@ void ProjectFileIO::Compact(
|
|||||||
OpenConnection(origName);
|
OpenConnection(origName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Did not achieve any real compaction
|
||||||
|
// RemoveProject not needed for what was an attached database
|
||||||
wxRemoveFile(tempName);
|
wxRemoveFile(tempName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2174,9 +2184,7 @@ bool ProjectFileIO::CloseProject()
|
|||||||
wxFileName file(filename);
|
wxFileName file(filename);
|
||||||
file.SetFullName(wxT(""));
|
file.SetFullName(wxT(""));
|
||||||
if (file == temp)
|
if (file == temp)
|
||||||
{
|
RemoveProject(filename);
|
||||||
wxRemoveFile(filename);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,6 +137,9 @@ private:
|
|||||||
bool MoveProject(const FilePath &src, const FilePath &dst);
|
bool MoveProject(const FilePath &src, const FilePath &dst);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
//! Remove any files associated with a project at given path; return true if successful
|
||||||
|
static bool RemoveProject(const FilePath &filename);
|
||||||
|
|
||||||
// Object manages the temporary backing-up of project paths while
|
// Object manages the temporary backing-up of project paths while
|
||||||
// trying to overwrite with new contents, and restoration in case of failure
|
// trying to overwrite with new contents, and restoration in case of failure
|
||||||
class BackupProject {
|
class BackupProject {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user