mirror of
https://github.com/audacity/audacity-project-tools.git
synced 2026-02-03 19:46:27 -06:00
Cleanup journal files on finish
This commit is contained in:
parent
956b312035
commit
edd0a14a52
9
.gitignore
vendored
9
.gitignore
vendored
@ -36,3 +36,12 @@ build/**
|
||||
out/**
|
||||
.venv/**
|
||||
CMakeUserPresets.json
|
||||
|
||||
# Audacity files
|
||||
|
||||
*.aup3
|
||||
*.aup4
|
||||
*.aup3-shm
|
||||
*.aup3-wal
|
||||
*.aup4-shm
|
||||
*.aup4-wal
|
||||
|
||||
@ -132,6 +132,12 @@ AudacityDatabase::AudacityDatabase(
|
||||
}, true);
|
||||
}
|
||||
|
||||
AudacityDatabase::~AudacityDatabase()
|
||||
{
|
||||
mDatabase.reset();
|
||||
removeJournalFiles(mReadOnly ? mProjectPath : mWritablePath);
|
||||
}
|
||||
|
||||
void AudacityDatabase::reopenReadonlyAsWritable()
|
||||
{
|
||||
if (!mReadOnly)
|
||||
@ -466,22 +472,26 @@ void AudacityDatabase::extractTrack(
|
||||
waveFile.writeFile();
|
||||
}
|
||||
|
||||
void AudacityDatabase::removeJournalFiles(const std::filesystem::path& dbPath)
|
||||
{
|
||||
auto walFile = dbPath;
|
||||
walFile.replace_extension("aup3-wal");
|
||||
|
||||
if (std::filesystem::exists(walFile))
|
||||
std::filesystem::remove(walFile);
|
||||
|
||||
auto shmFile = dbPath;
|
||||
shmFile.replace_extension("aup3-shm");
|
||||
|
||||
if (std::filesystem::exists(shmFile))
|
||||
std::filesystem::remove(shmFile);
|
||||
}
|
||||
|
||||
void AudacityDatabase::removeOldFiles()
|
||||
{
|
||||
if (std::filesystem::exists(mWritablePath))
|
||||
{
|
||||
std::filesystem::remove(mWritablePath);
|
||||
|
||||
auto walFile = mWritablePath;
|
||||
walFile.replace_extension("aup3-wal");
|
||||
|
||||
if (std::filesystem::exists(walFile))
|
||||
std::filesystem::remove(walFile);
|
||||
|
||||
auto shmFile = mWritablePath;
|
||||
shmFile.replace_extension("aup3-shm");
|
||||
|
||||
if (std::filesystem::exists(shmFile))
|
||||
std::filesystem::remove(shmFile);
|
||||
removeJournalFiles(mWritablePath);
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,6 +24,7 @@ class AudacityDatabase final
|
||||
public:
|
||||
explicit AudacityDatabase(
|
||||
const std::filesystem::path& path, RecoveryConfig recoveryConfig);
|
||||
~AudacityDatabase();
|
||||
|
||||
void reopenReadonlyAsWritable();
|
||||
void recoverDatabase();
|
||||
@ -43,6 +44,7 @@ public:
|
||||
void extractTrack(SampleFormat format, int32_t sampleRate, bool asStereo);
|
||||
|
||||
private:
|
||||
static void removeJournalFiles(const std::filesystem::path& dbPath);
|
||||
void removeOldFiles();
|
||||
|
||||
std::unique_ptr<SQLite::Database> mDatabase;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user