1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-12-31 17:08:45 +01:00

Bug2550 residual: also move -shm file if present...

... Also much other extra care in the handling of -shm and -wal files
This commit is contained in:
Paul Licameli
2020-11-22 12:20:05 -05:00
parent b32ce8ab21
commit 3e0120be05
3 changed files with 182 additions and 59 deletions

View File

@@ -121,6 +121,37 @@ public:
// ProjectManager::OnCloseWindow()
void SetBypass();
private:
//! Strings like -wal that may be appended to main project name to get other files created by
//! the database system
static const std::vector<wxString> &AuxiliaryFileSuffixes();
//! Generate a name for short-lived backup project files from an existing project
static FilePath SafetyFileName(const FilePath &src);
//! Rename a file or put up appropriate warning message.
/*! Failure might happen when renaming onto another device, doing copy of contents */
bool RenameOrWarn(const FilePath &src, const FilePath &dst);
bool MoveProject(const FilePath &src, const FilePath &dst);
public:
// Object manages the temporary backing-up of project paths while
// trying to overwrite with new contents, and restoration in case of failure
class BackupProject {
public:
//! Rename project file at path, and any auxiliary files, to backup path names
BackupProject( ProjectFileIO &projectFileIO, const FilePath &path );
//! Returns false if the renaming in the constructor failed
bool IsOk() { return !mPath.empty(); }
//! if `!IsOk()` do nothing; else remove backup files
void Discard();
//! if `!IsOk()` do nothing; else if `Discard()` was not called, undo the renaming
~BackupProject();
private:
FilePath mPath, mSafety;
};
// Remove all unused space within a project file
void Compact(
const std::vector<const TrackList *> &tracks, bool force = false);