1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-01-09 14:17:10 +01:00

Bug2592: should clean old temp directory at exit after prefs change

This commit is contained in:
Paul Licameli
2020-11-22 15:43:24 -05:00
parent 3e0120be05
commit 8cb6749741
4 changed files with 19 additions and 3 deletions

View File

@@ -1637,6 +1637,7 @@ bool AudacityApp::InitTempDir()
chmod(OSFILENAME(temp), 0755);
#endif
FileNames::ResetTempDir();
FileNames::UpdateDefaultPath(FileNames::Operation::Temp, temp);
// Make sure the temp dir isn't locked by another process.

View File

@@ -196,13 +196,28 @@ wxString FileNames::MkDir(const wxString &Str)
return Str;
}
static wxString &TempDirPath()
{
static wxString path;
return path;
}
/// Returns the directory used for temp files.
/// \todo put a counter in here to see if it gets used a lot.
/// if it does, then maybe we should cache the path name
/// each time.
wxString FileNames::TempDir()
{
return FileNames::MkDir(gPrefs->Read(PreferenceKey(Operation::Temp, PathType::_None), wxT("")));
auto &path = TempDirPath();
if (gPrefs && path.empty())
path =
gPrefs->Read(PreferenceKey(Operation::Temp, PathType::_None), wxT(""));
return FileNames::MkDir(path);
}
void FileNames::ResetTempDir()
{
TempDirPath().clear();
}
// originally an ExportMultipleDialog method. Append suffix if newName appears in otherNames.

View File

@@ -66,6 +66,7 @@ namespace FileNames
wxString MkDir(const wxString &Str);
wxString TempDir();
void ResetTempDir();
const FilePath &DefaultTempDir();
void SetDefaultTempDir( const FilePath &tempDir );

View File

@@ -1014,8 +1014,7 @@ bool ProjectFileIO::RenameOrWarn(const FilePath &src, const FilePath &dst)
bool ProjectFileIO::MoveProject(const FilePath &src, const FilePath &dst)
{
// Assume the src database file is not busy.
if (!RenameOrWarn(src, dst))
// Assume the src database file is not busy. if (!RenameOrWarn(src, dst))
return false;
// So far so good, but the separate -wal and -shm files might yet exist,