@@ -132,6 +132,12 @@ AudacityDatabase::AudacityDatabase(
132132 }, true );
133133}
134134
135+ AudacityDatabase::~AudacityDatabase ()
136+ {
137+ mDatabase .reset ();
138+ removeJournalFiles (mReadOnly ? mProjectPath : mWritablePath );
139+ }
140+
135141void AudacityDatabase::reopenReadonlyAsWritable ()
136142{
137143 if (!mReadOnly )
@@ -466,22 +472,26 @@ void AudacityDatabase::extractTrack(
466472 waveFile.writeFile ();
467473}
468474
469- void AudacityDatabase::removeOldFiles ( )
475+ void AudacityDatabase::removeJournalFiles ( const std::filesystem::path& dbPath )
470476{
471- if (std::filesystem::exists (mWritablePath ))
472- {
473- std::filesystem::remove (mWritablePath );
477+ auto walFile = dbPath;
478+ walFile.replace_extension (" aup3-wal" );
474479
475- auto walFile = mWritablePath ;
476- walFile. replace_extension ( " aup3-wal " );
480+ if ( std::filesystem::exists ( walFile))
481+ std::filesystem::remove (walFile );
477482
478- if ( std::filesystem::exists (walFile))
479- std::filesystem::remove (walFile );
483+ auto shmFile = dbPath;
484+ shmFile. replace_extension ( " aup3-shm " );
480485
481- auto shmFile = mWritablePath ;
482- shmFile.replace_extension (" aup3-shm" );
486+ if (std::filesystem::exists (shmFile))
487+ std::filesystem::remove (shmFile);
488+ }
483489
484- if (std::filesystem::exists (shmFile))
485- std::filesystem::remove (shmFile);
490+ void AudacityDatabase::removeOldFiles ()
491+ {
492+ if (std::filesystem::exists (mWritablePath ))
493+ {
494+ std::filesystem::remove (mWritablePath );
495+ removeJournalFiles (mWritablePath );
486496 }
487497}
0 commit comments