mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-21 08:27:13 +01:00
Bug 1271 - Move the Audacity temp dir to a location not scanned by cleanup apps (Residual)
The residual issue here was that an old cfg could go on using the unsafe path. So we check for the unsafe path at init and silently substitute the good path. If the user attempts to re-instate the unsafe path we tell them no, with an informative message. This change was made more complex by windows allowing different strings for the same path, specifically C:\Users\JAMESC~1\AppData\Local\Temp\audacity_temp contains the shortening '~' so in the function that tests 'IsTempDirectoryNameOK' we use GetLongPath() to always compare the expanded names. I also changed directory prefs to add SessionData rather than audacity_temp on the new directory name, on windows when choosing a new temp directory.
This commit is contained in:
@@ -1504,6 +1504,24 @@ void AudacityApp::OnReceiveCommand(AppCommandEvent &event)
|
||||
mCmdHandler->OnReceiveCommand(event);
|
||||
}
|
||||
|
||||
// We now disallow temp directory name that puts it where cleaner apps will
|
||||
// try to clean out the files.
|
||||
bool AudacityApp::IsTempDirectoryNameOK( const wxString & Name ){
|
||||
#ifndef __WXMSW__
|
||||
return true;
|
||||
#else
|
||||
wxFileName tmpFile;
|
||||
tmpFile.AssignTempFileName(wxT("nn"));
|
||||
// use Long Path to expand out any abbreviated long substrings.
|
||||
wxString BadPath = tmpFile.GetLongPath();
|
||||
::wxRemoveFile(tmpFile.GetFullPath());
|
||||
BadPath = BadPath.BeforeLast( '\\' ) + "\\";
|
||||
wxFileName cmpFile( Name );
|
||||
wxString NameCanonical = cmpFile.GetLongPath( ) + "\\";
|
||||
return !(NameCanonical.StartsWith( BadPath ));
|
||||
#endif
|
||||
}
|
||||
|
||||
bool AudacityApp::InitTempDir()
|
||||
{
|
||||
// We need to find a temp directory location.
|
||||
@@ -1523,8 +1541,9 @@ bool AudacityApp::InitTempDir()
|
||||
wxLogNull logNo;
|
||||
|
||||
// Try temp dir that was stored in prefs first
|
||||
|
||||
if (tempFromPrefs != wxT("")) {
|
||||
if( !IsTempDirectoryNameOK( tempFromPrefs ) ){
|
||||
;// Bad name? Don't try and use it.
|
||||
} else if (tempFromPrefs != wxT("")) {
|
||||
if (wxDirExists(tempFromPrefs))
|
||||
temp = tempFromPrefs;
|
||||
else if (wxMkdir(tempFromPrefs, 0755))
|
||||
@@ -1555,7 +1574,11 @@ bool AudacityApp::InitTempDir()
|
||||
|
||||
if (temp == wxT("")) {
|
||||
// Failed
|
||||
wxMessageBox(_("Audacity could not find a place to store temporary files.\nPlease enter an appropriate directory in the preferences dialog."));
|
||||
if( !IsTempDirectoryNameOK( tempFromPrefs ) ) {
|
||||
wxMessageBox(_("Audacity could not find a safe place to store temporary files.\nAudacity needs a place where automatic cleanup programs won't delete the temporary files.\nPlease enter an appropriate directory in the preferences dialog."));
|
||||
} else {
|
||||
wxMessageBox(_("Audacity could not find a place to store temporary files.\nPlease enter an appropriate directory in the preferences dialog."));
|
||||
}
|
||||
|
||||
// Only want one page of the preferences
|
||||
DirectoriesPrefsFactory directoriesPrefsFactory;
|
||||
|
||||
Reference in New Issue
Block a user