mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-16 16:10:06 +02:00
(bug 20, P2)
Changed the bSilentlyCorrect parameter to DirManager::ProjectFSCK() to be bAutoRecoverMode. If project check errors are found during auto-recovery, it's hazardous to allow the user the various options available during normal project open. But rather than squelching the messages as well as option dialogs during auto-recover, show the messages in the log and bring up an alert. This means the helper methods Find*() no longer need bSilentlyCorrect -- they always report to the log.
This commit is contained in:
parent
c43b3bc387
commit
a26652acfd
@ -1388,7 +1388,7 @@ void DirManager::Deref()
|
|||||||
// by history) will be reflected in the mBlockFileHash, and that's a
|
// by history) will be reflected in the mBlockFileHash, and that's a
|
||||||
// good thing; this is one reason why we use the hash and not the most
|
// good thing; this is one reason why we use the hash and not the most
|
||||||
// recent savefile.
|
// recent savefile.
|
||||||
int DirManager::ProjectFSCK(const bool bForceError, const bool bSilentlyCorrect)
|
int DirManager::ProjectFSCK(const bool bForceError, const bool bAutoRecoverMode)
|
||||||
{
|
{
|
||||||
wxArrayString filePathArray; // *all* files in the project directory/subdirectories
|
wxArrayString filePathArray; // *all* files in the project directory/subdirectories
|
||||||
wxString dirPath = (projFull != wxT("") ? projFull : mytemp);
|
wxString dirPath = (projFull != wxT("") ? projFull : mytemp);
|
||||||
@ -1417,14 +1417,14 @@ int DirManager::ProjectFSCK(const bool bForceError, const bool bSilentlyCorrect)
|
|||||||
//
|
//
|
||||||
BlockHash missingAliasedFileAUFHash; // (.auf) AliasBlockFiles whose aliased files are missing
|
BlockHash missingAliasedFileAUFHash; // (.auf) AliasBlockFiles whose aliased files are missing
|
||||||
BlockHash missingAliasedFilePathHash; // full paths of missing aliased files
|
BlockHash missingAliasedFilePathHash; // full paths of missing aliased files
|
||||||
this->FindMissingAliasedFiles(bSilentlyCorrect, missingAliasedFileAUFHash, missingAliasedFilePathHash);
|
this->FindMissingAliasedFiles(missingAliasedFileAUFHash, missingAliasedFilePathHash);
|
||||||
|
|
||||||
// No need to check (nResult != FSCKstatus_CLOSE_REQ) as this is first check.
|
// No need to check (nResult != FSCKstatus_CLOSE_REQ) as this is first check.
|
||||||
if (!missingAliasedFileAUFHash.empty())
|
if (!missingAliasedFileAUFHash.empty())
|
||||||
{
|
{
|
||||||
// In "silently correct" mode, we always create silent blocks, so do not ask user.
|
// In auto-recover mode, we always create silent blocks, and do not ask user.
|
||||||
// This makes sure the project is complete next time we open it.
|
// This makes sure the project is complete next time we open it.
|
||||||
if (bSilentlyCorrect)
|
if (bAutoRecoverMode)
|
||||||
action = 2;
|
action = 2;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1483,12 +1483,12 @@ _("Project check detected %d missing external audio \
|
|||||||
// Alias summary regeneration must happen after checking missing aliased files.
|
// Alias summary regeneration must happen after checking missing aliased files.
|
||||||
//
|
//
|
||||||
BlockHash missingAUFHash; // missing (.auf) AliasBlockFiles
|
BlockHash missingAUFHash; // missing (.auf) AliasBlockFiles
|
||||||
this->FindMissingAUFs(bSilentlyCorrect, missingAUFHash);
|
this->FindMissingAUFs(missingAUFHash);
|
||||||
if ((nResult != FSCKstatus_CLOSE_REQ) && !missingAUFHash.empty())
|
if ((nResult != FSCKstatus_CLOSE_REQ) && !missingAUFHash.empty())
|
||||||
{
|
{
|
||||||
// In "silently correct" mode, we just recreate the alias files, so do not ask user.
|
// In auto-recover mode, we just recreate the alias files, and do not ask user.
|
||||||
// This makes sure the project is complete next time we open it.
|
// This makes sure the project is complete next time we open it.
|
||||||
if (bSilentlyCorrect)
|
if (bAutoRecoverMode)
|
||||||
action = 0;
|
action = 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1531,12 +1531,12 @@ _("Project check detected %d missing alias (.auf) \
|
|||||||
// MISSING (.AU) SimpleBlockFiles
|
// MISSING (.AU) SimpleBlockFiles
|
||||||
//
|
//
|
||||||
BlockHash missingAUHash; // missing data (.au) blockfiles
|
BlockHash missingAUHash; // missing data (.au) blockfiles
|
||||||
this->FindMissingAUs(bSilentlyCorrect, missingAUHash);
|
this->FindMissingAUs(missingAUHash);
|
||||||
if ((nResult != FSCKstatus_CLOSE_REQ) && !missingAUHash.empty())
|
if ((nResult != FSCKstatus_CLOSE_REQ) && !missingAUHash.empty())
|
||||||
{
|
{
|
||||||
// In "silently correct" mode, we just always create silent blocks.
|
// In auto-recover mode, we just always create silent blocks.
|
||||||
// This makes sure the project is complete next time we open it.
|
// This makes sure the project is complete next time we open it.
|
||||||
if (bSilentlyCorrect)
|
if (bAutoRecoverMode)
|
||||||
action = 2;
|
action = 2;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1586,11 +1586,11 @@ _("Project check detected %d missing audio data \
|
|||||||
// MISSING ORPHAN BLOCKFILES (.AU AND .AUF)
|
// MISSING ORPHAN BLOCKFILES (.AU AND .AUF)
|
||||||
//
|
//
|
||||||
wxArrayString orphanFilePathArray; // orphan .au and .auf files
|
wxArrayString orphanFilePathArray; // orphan .au and .auf files
|
||||||
this->FindOrphanBlockFiles(bSilentlyCorrect, filePathArray, orphanFilePathArray);
|
this->FindOrphanBlockFiles(filePathArray, orphanFilePathArray);
|
||||||
|
|
||||||
// In "silently correct" mode, leave orphan blockfiles alone.
|
// In auto-recover mode, leave orphan blockfiles alone.
|
||||||
// They will be deleted when project is saved the first time.
|
// They will be deleted when project is saved the first time.
|
||||||
if ((nResult != FSCKstatus_CLOSE_REQ) && !bSilentlyCorrect && !orphanFilePathArray.IsEmpty())
|
if ((nResult != FSCKstatus_CLOSE_REQ) && !bAutoRecoverMode && !orphanFilePathArray.IsEmpty())
|
||||||
{
|
{
|
||||||
wxString msgA =
|
wxString msgA =
|
||||||
_("Project check found %d orphan blockfile(s). These files are \
|
_("Project check found %d orphan blockfile(s). These files are \
|
||||||
@ -1635,21 +1635,26 @@ _("Project check found %d orphan blockfile(s). These files are \
|
|||||||
|
|
||||||
// Summarize and flush the log.
|
// Summarize and flush the log.
|
||||||
if (bForceError ||
|
if (bForceError ||
|
||||||
(!bSilentlyCorrect &&
|
!missingAliasedFileAUFHash.empty() ||
|
||||||
(!missingAliasedFileAUFHash.empty() ||
|
!missingAUFHash.empty() ||
|
||||||
!missingAUFHash.empty() ||
|
!missingAUHash.empty() ||
|
||||||
!missingAUHash.empty() ||
|
!orphanFilePathArray.IsEmpty())
|
||||||
!orphanFilePathArray.IsEmpty())))
|
|
||||||
{
|
{
|
||||||
wxLogWarning(_("Project check found inconsistencies inspecting the loaded project data."));
|
wxLogWarning(_("Project check found file inconsistencies inspecting the loaded project data."));
|
||||||
wxLog::FlushActive(); // Flush is modal and will clear the log (both desired).
|
wxLog::FlushActive(); // Flush is modal and will clear the log (both desired).
|
||||||
|
|
||||||
|
// In auto-recover mode, we didn't do any ShowMultiDialog calls above, so put up an alert.
|
||||||
|
if (bAutoRecoverMode)
|
||||||
|
::wxMessageBox(
|
||||||
|
_("Project check found file inconsistencies during automatic recovery.\n\nSelect 'Show Log...' in the Help menu to see details."),
|
||||||
|
_("Warning: Problems in Automatic Recovery"),
|
||||||
|
wxOK | wxICON_EXCLAMATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
return nResult;
|
return nResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DirManager::FindMissingAliasedFiles(
|
void DirManager::FindMissingAliasedFiles(
|
||||||
const bool bSilentlyCorrect, // input: same as for ProjectFSCK
|
|
||||||
BlockHash& missingAliasedFileAUFHash, // output: (.auf) AliasBlockFiles whose aliased files are missing
|
BlockHash& missingAliasedFileAUFHash, // output: (.auf) AliasBlockFiles whose aliased files are missing
|
||||||
BlockHash& missingAliasedFilePathHash) // output: full paths of missing aliased files
|
BlockHash& missingAliasedFilePathHash) // output: full paths of missing aliased files
|
||||||
{
|
{
|
||||||
@ -1669,24 +1674,23 @@ void DirManager::FindMissingAliasedFiles(
|
|||||||
missingAliasedFileAUFHash[key] = b;
|
missingAliasedFileAUFHash[key] = b;
|
||||||
if (missingAliasedFilePathHash.find(aliasedFileFullPath) ==
|
if (missingAliasedFilePathHash.find(aliasedFileFullPath) ==
|
||||||
missingAliasedFilePathHash.end()) // Add it only once.
|
missingAliasedFilePathHash.end()) // Add it only once.
|
||||||
missingAliasedFilePathHash[aliasedFileFullPath] = NULL; // Not really using the blocks here.
|
// Not actually using the block here, just the path,
|
||||||
|
// so set the block to NULL to create the entry.
|
||||||
|
missingAliasedFilePathHash[aliasedFileFullPath] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iter++;
|
iter++;
|
||||||
}
|
}
|
||||||
if (!bSilentlyCorrect)
|
|
||||||
|
iter = missingAliasedFilePathHash.begin();
|
||||||
|
while (iter != missingAliasedFilePathHash.end())
|
||||||
{
|
{
|
||||||
iter = missingAliasedFilePathHash.begin();
|
wxLogWarning(_("Missing aliased audio file: '%s'"), iter->first.c_str());
|
||||||
while (iter != missingAliasedFilePathHash.end())
|
iter++;
|
||||||
{
|
|
||||||
wxLogWarning(_("Missing aliased audio file: '%s'"), iter->first.c_str());
|
|
||||||
iter++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DirManager::FindMissingAUFs(
|
void DirManager::FindMissingAUFs(
|
||||||
const bool bSilentlyCorrect, // input: same as for ProjectFSCK
|
|
||||||
BlockHash& missingAUFHash) // output: missing (.auf) AliasBlockFiles
|
BlockHash& missingAUFHash) // output: missing (.auf) AliasBlockFiles
|
||||||
{
|
{
|
||||||
BlockHash::iterator iter = mBlockFileHash.begin();
|
BlockHash::iterator iter = mBlockFileHash.begin();
|
||||||
@ -1704,9 +1708,8 @@ void DirManager::FindMissingAUFs(
|
|||||||
if (!fileName.FileExists())
|
if (!fileName.FileExists())
|
||||||
{
|
{
|
||||||
missingAUFHash[key] = b;
|
missingAUFHash[key] = b;
|
||||||
if (!bSilentlyCorrect)
|
wxLogWarning(_("Missing alias (.auf) blockfile: '%s'"),
|
||||||
wxLogWarning(_("Missing alias (.auf) blockfile: '%s'"),
|
fileName.GetFullPath().c_str());
|
||||||
fileName.GetFullPath().c_str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iter++;
|
iter++;
|
||||||
@ -1714,7 +1717,6 @@ void DirManager::FindMissingAUFs(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DirManager::FindMissingAUs(
|
void DirManager::FindMissingAUs(
|
||||||
const bool bSilentlyCorrect, // input: same as for ProjectFSCK
|
|
||||||
BlockHash& missingAUHash) // missing data (.au) blockfiles
|
BlockHash& missingAUHash) // missing data (.au) blockfiles
|
||||||
{
|
{
|
||||||
BlockHash::iterator iter = mBlockFileHash.begin();
|
BlockHash::iterator iter = mBlockFileHash.begin();
|
||||||
@ -1730,17 +1732,16 @@ void DirManager::FindMissingAUs(
|
|||||||
if (!fileName.FileExists())
|
if (!fileName.FileExists())
|
||||||
{
|
{
|
||||||
missingAUHash[key] = b;
|
missingAUHash[key] = b;
|
||||||
if (!bSilentlyCorrect)
|
wxLogWarning(_("Missing data blockfile: '%s'"),
|
||||||
wxLogWarning(_("Missing data blockfile: '%s'"),
|
fileName.GetFullPath().c_str());
|
||||||
fileName.GetFullPath().c_str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iter++;
|
iter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DirManager::FindOrphanBlockFiles( // Find .au and .auf files that are not in the project.
|
// Find .au and .auf files that are not in the project.
|
||||||
const bool bSilentlyCorrect, // input: same as for ProjectFSCK
|
void DirManager::FindOrphanBlockFiles(
|
||||||
const wxArrayString& filePathArray, // input: all files in project directory
|
const wxArrayString& filePathArray, // input: all files in project directory
|
||||||
wxArrayString& orphanFilePathArray) // output: orphan files
|
wxArrayString& orphanFilePathArray) // output: orphan files
|
||||||
{
|
{
|
||||||
@ -1757,11 +1758,11 @@ void DirManager::FindOrphanBlockFiles( // Find .au and .auf files that
|
|||||||
orphanFilePathArray.Add(fullname.GetFullPath());
|
orphanFilePathArray.Add(fullname.GetFullPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!bSilentlyCorrect)
|
for (size_t i = 0; i < orphanFilePathArray.GetCount(); i++)
|
||||||
for (size_t i = 0; i < orphanFilePathArray.GetCount(); i++)
|
wxLogWarning(_("Orphan blockfile: '%s'"), orphanFilePathArray[i].c_str());
|
||||||
wxLogWarning(_("Orphan blockfile: '%s'"), orphanFilePathArray[i].c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DirManager::RemoveOrphanBlockfiles()
|
void DirManager::RemoveOrphanBlockfiles()
|
||||||
{
|
{
|
||||||
wxArrayString filePathArray; // *all* files in the project directory/subdirectories
|
wxArrayString filePathArray; // *all* files in the project directory/subdirectories
|
||||||
@ -1776,7 +1777,6 @@ void DirManager::RemoveOrphanBlockfiles()
|
|||||||
|
|
||||||
wxArrayString orphanFilePathArray;
|
wxArrayString orphanFilePathArray;
|
||||||
this->FindOrphanBlockFiles(
|
this->FindOrphanBlockFiles(
|
||||||
true,
|
|
||||||
filePathArray, // input: all files in project directory tree
|
filePathArray, // input: all files in project directory tree
|
||||||
orphanFilePathArray); // output: orphan files
|
orphanFilePathArray); // output: orphan files
|
||||||
|
|
||||||
|
@ -109,31 +109,25 @@ class DirManager: public XMLTagHandler {
|
|||||||
static void CleanTempDir();
|
static void CleanTempDir();
|
||||||
|
|
||||||
// Check the project for errors and possibly prompt user
|
// Check the project for errors and possibly prompt user
|
||||||
//
|
// bForceError: Always show log error alert even if no errors are found here.
|
||||||
// bForceError: Always show log error dialog even if no errors are found
|
// Important when you know that there are already errors in the log.
|
||||||
// Important when you know that there are already errors in
|
// bAutoRecoverMode: Do not show any option dialogs for how to deal with errors found here.
|
||||||
// the log
|
// Too complicated during auto-recover. Just correct problems the "safest" way.
|
||||||
//
|
int ProjectFSCK(const bool bForceError, const bool bAutoRecoverMode);
|
||||||
// bSilentlyCorrect: Do not show an error dialog (except if bForceError is
|
|
||||||
// true) and silently correct problems the "safest" way.
|
|
||||||
//
|
|
||||||
int ProjectFSCK(const bool bForceError, const bool bSilentlyCorrect);
|
|
||||||
|
|
||||||
void FindMissingAliasedFiles(
|
void FindMissingAliasedFiles(
|
||||||
const bool bSilentlyCorrect, // input: true => do not log warnings on files
|
|
||||||
BlockHash& missingAliasedFileAUFHash, // output: (.auf) AliasBlockFiles whose aliased files are missing
|
BlockHash& missingAliasedFileAUFHash, // output: (.auf) AliasBlockFiles whose aliased files are missing
|
||||||
BlockHash& missingAliasedFilePathHash); // output: full paths of missing aliased files
|
BlockHash& missingAliasedFilePathHash); // output: full paths of missing aliased files
|
||||||
void FindMissingAUFs(
|
void FindMissingAUFs(
|
||||||
const bool bSilentlyCorrect, // input: true => do not log warnings on files
|
|
||||||
BlockHash& missingAUFHash); // output: missing (.auf) AliasBlockFiles
|
BlockHash& missingAUFHash); // output: missing (.auf) AliasBlockFiles
|
||||||
void FindMissingAUs(
|
void FindMissingAUs(
|
||||||
const bool bSilentlyCorrect, // input: true => do not log warnings on files
|
|
||||||
BlockHash& missingAUHash); // missing data (.au) blockfiles
|
BlockHash& missingAUHash); // missing data (.au) blockfiles
|
||||||
void FindOrphanBlockFiles( // Find .au and .auf files that are not in the project.
|
// Find .au and .auf files that are not in the project.
|
||||||
const bool bSilentlyCorrect, // input: true => do not log warnings on files
|
void FindOrphanBlockFiles(
|
||||||
const wxArrayString& filePathArray, // input: all files in project directory
|
const wxArrayString& filePathArray, // input: all files in project directory
|
||||||
wxArrayString& orphanFilePathArray); // output: orphan files
|
wxArrayString& orphanFilePathArray); // output: orphan files
|
||||||
|
|
||||||
|
|
||||||
// Remove all orphaned blockfiles without user interaction. This is
|
// Remove all orphaned blockfiles without user interaction. This is
|
||||||
// generally safe, because orphaned blockfiles are not referenced by the
|
// generally safe, because orphaned blockfiles are not referenced by the
|
||||||
// project and thus worthless anyway.
|
// project and thus worthless anyway.
|
||||||
|
@ -2444,7 +2444,7 @@ void AudacityProject::OpenFile(wxString fileName, bool addtohistory)
|
|||||||
// at this point mFileName != fileName, because when opening a
|
// at this point mFileName != fileName, because when opening a
|
||||||
// recovered file mFileName is faked to point to the original file
|
// recovered file mFileName is faked to point to the original file
|
||||||
// which has been recovered, not the one in the auto-save folder.
|
// which has been recovered, not the one in the auto-save folder.
|
||||||
GetDirManager()->ProjectFSCK(err, true); // silently correct problems
|
GetDirManager()->ProjectFSCK(err, true); // Correct problems in auto-recover mode.
|
||||||
|
|
||||||
// PushState calls AutoSave(), so no longer need to do so here.
|
// PushState calls AutoSave(), so no longer need to do so here.
|
||||||
this->PushState(_("Project was recovered"), _("Recover"));
|
this->PushState(_("Project was recovered"), _("Recover"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user