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:
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -66,6 +66,7 @@ namespace FileNames
|
||||
|
||||
wxString MkDir(const wxString &Str);
|
||||
wxString TempDir();
|
||||
void ResetTempDir();
|
||||
|
||||
const FilePath &DefaultTempDir();
|
||||
void SetDefaultTempDir( const FilePath &tempDir );
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user