1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-01 08:29:27 +02:00

(bug 113)

Comments about what's wrong with the DirManager::ProjectFSCK "Missing Aliased Files" dialog actions and what to do about it. (More to follow!)

Changed PushState for project repair from "Repair" to "Project Repair" to distinguish from Repair effect.

renames for clarity
This commit is contained in:
v.audacity 2010-08-01 00:04:23 +00:00
parent be83111226
commit a6cb3debe9
7 changed files with 68 additions and 68 deletions

View File

@ -627,17 +627,10 @@ bool AliasBlockFile::ReadSummary(void *data)
return (read == mSummaryInfo.totalSummaryBytes); return (read == mSummaryInfo.totalSummaryBytes);
} }
/// Get the name of the file where the audio data for this block is
/// stored.
wxFileName AliasBlockFile::GetAliasedFile()
{
return mAliasedFileName;
}
/// Modify this block to point at a different file. This is generally /// Modify this block to point at a different file. This is generally
/// looked down on, but it is necessary in one case: see /// looked down on, but it is necessary in one case: see
/// DirManager::EnsureSafeFilename(). /// DirManager::EnsureSafeFilename().
void AliasBlockFile::ChangeAliasedFile(wxFileName newAliasedFile) void AliasBlockFile::ChangeAliasedFileName(wxFileName newAliasedFile)
{ {
mAliasedFileName = newAliasedFile; mAliasedFileName = newAliasedFile;
} }
@ -648,15 +641,3 @@ wxLongLong AliasBlockFile::GetSpaceUsage()
return summaryFile.Length(); return summaryFile.Length();
} }
// Indentation settings for Vim and Emacs and unique identifier for Arch, a
// version control system. Please do not modify past this point.
//
// Local Variables:
// c-basic-offset: 3
// indent-tabs-mode: nil
// End:
//
// vim: et sts=3 sw=3
// arch-tag: a38e6501-f14a-4428-902d-17af1847cb59

View File

@ -212,16 +212,11 @@ class AliasBlockFile : public BlockFile
// applying to Alias file access // applying to Alias file access
void SilenceAliasLog() { mSilentAliasLog = TRUE; } void SilenceAliasLog() { mSilentAliasLog = TRUE; }
// //
// These methods are for advanced use only! // These methods are for advanced use only!
// //
wxFileName GetAliasedFileName() { return mAliasedFileName; };
/// Gets the name of the aliased file. void ChangeAliasedFileName(wxFileName newAliasedFile);
wxFileName GetAliasedFile();
/// Modifies the name of the aliased file.
void ChangeAliasedFile(wxFileName newAliasedFile);
/// Returns TRUE if this is an AliasBlockFile
virtual bool IsAlias() { return true; } virtual bool IsAlias() { return true; }
protected: protected:

View File

@ -141,7 +141,16 @@ void FindDependencies(AudacityProject *project,
// f is an alias block we have not yet counted. // f is an alias block we have not yet counted.
blockFileHash[f] = true; // Don't count the same blockfile twice. blockFileHash[f] = true; // Don't count the same blockfile twice.
AliasBlockFile *aliasBlockFile = (AliasBlockFile *)f; AliasBlockFile *aliasBlockFile = (AliasBlockFile *)f;
wxFileName fileName = aliasBlockFile->GetAliasedFile(); wxFileName fileName = aliasBlockFile->GetAliasedFileName();
// In DirManager::ProjectFSCK(), if the user has chosen to
// "Replace missing audio with silence (permanent upon save)",
// the code there puts in an empty wxFileName.
// Don't count those in dependencies.
//vvvvv REMOVE THIS WHEN DirManager::ProjectFSCK() DOES THE RIGHT THING!
if (!fileName.IsOk())
continue;
wxString fileNameStr = fileName.GetFullPath(); wxString fileNameStr = fileName.GetFullPath();
int blockBytes = (SAMPLE_SIZE(format) * int blockBytes = (SAMPLE_SIZE(format) *
aliasBlockFile->GetLength()); aliasBlockFile->GetLength());
@ -199,7 +208,7 @@ void RemoveDependencies(AudacityProject *project,
{ {
// f is an alias block we have not yet processed. // f is an alias block we have not yet processed.
AliasBlockFile *aliasBlockFile = (AliasBlockFile *)f; AliasBlockFile *aliasBlockFile = (AliasBlockFile *)f;
wxFileName fileName = aliasBlockFile->GetAliasedFile(); wxFileName fileName = aliasBlockFile->GetAliasedFileName();
wxString fileNameStr = fileName.GetFullPath(); wxString fileNameStr = fileName.GetFullPath();
if (aliasedFileHash.count(fileNameStr) == 0) if (aliasedFileHash.count(fileNameStr) == 0)

View File

@ -1203,36 +1203,36 @@ bool DirManager::EnsureSafeFilename(wxFileName fName)
/* i18n-hint: e.g. Try to go from "mysong.wav" to "mysong-old1.wav". */ /* i18n-hint: e.g. Try to go from "mysong.wav" to "mysong-old1.wav". */
// Keep trying until we find a filename that doesn't exist. // Keep trying until we find a filename that doesn't exist.
wxFileName renamedFile = fName; wxFileName renamedFileName = fName;
int i = 0; int i = 0;
do { do {
i++; i++;
/* i18n-hint: This is the pattern for filenames that are created /* i18n-hint: This is the pattern for filenames that are created
when a file needs to be backed up to a different name. For when a file needs to be backed up to a different name. For
example, mysong would become mysong-old1, mysong-old2, etc. */ example, mysong would become mysong-old1, mysong-old2, etc. */
renamedFile.SetName(wxString::Format(_("%s-old%d"), fName.GetName().c_str(), i)); renamedFileName.SetName(wxString::Format(_("%s-old%d"), fName.GetName().c_str(), i));
} while (wxFileExists(renamedFile.GetFullPath())); } while (wxFileExists(renamedFileName.GetFullPath()));
// Test creating a file by that name to make sure it will // Test creating a file by that name to make sure it will
// be possible to do the rename // be possible to do the rename
wxFile testFile(renamedFile.GetFullPath(), wxFile::write); wxFile testFile(renamedFileName.GetFullPath(), wxFile::write);
if (!testFile.IsOpened()) { if (!testFile.IsOpened()) {
wxLogSysError(_("Unable to open/create test file"), wxLogSysError(_("Unable to open/create test file"),
renamedFile.GetFullPath().c_str()); renamedFileName.GetFullPath().c_str());
return false; return false;
} }
// Close the file prior to renaming. // Close the file prior to renaming.
testFile.Close(); testFile.Close();
if (!wxRemoveFile(renamedFile.GetFullPath())) { if (!wxRemoveFile(renamedFileName.GetFullPath())) {
wxLogSysError(_("Unable to remove '%s'"), wxLogSysError(_("Unable to remove '%s'"),
renamedFile.GetFullPath().c_str()); renamedFileName.GetFullPath().c_str());
return false; return false;
} }
wxPrintf(_("Renamed file: %s\n"), renamedFile.GetFullPath().c_str()); wxPrintf(_("Renamed file: %s\n"), renamedFileName.GetFullPath().c_str());
// Go through our block files and see if any indeed point to // Go through our block files and see if any indeed point to
// the file we're concerned about. If so, point the block file // the file we're concerned about. If so, point the block file
@ -1246,7 +1246,7 @@ bool DirManager::EnsureSafeFilename(wxFileName fName)
// don't worry, we don't rely on this cast unless IsAlias is true // don't worry, we don't rely on this cast unless IsAlias is true
AliasBlockFile *ab = (AliasBlockFile*)b; AliasBlockFile *ab = (AliasBlockFile*)b;
if (b->IsAlias() && ab->GetAliasedFile() == fName) { if (b->IsAlias() && ab->GetAliasedFileName() == fName) {
needToRename = true; needToRename = true;
//ODBlocks access the aliased file on another thread, so we need to pause them before this continues. //ODBlocks access the aliased file on another thread, so we need to pause them before this continues.
@ -1269,7 +1269,7 @@ bool DirManager::EnsureSafeFilename(wxFileName fName)
if (needToRename) { if (needToRename) {
if (!wxRenameFile(fName.GetFullPath(), if (!wxRenameFile(fName.GetFullPath(),
renamedFile.GetFullPath())) renamedFileName.GetFullPath()))
{ {
// ACK!!! The renaming was unsuccessful!!! // ACK!!! The renaming was unsuccessful!!!
// (This shouldn't happen, since we tried creating a // (This shouldn't happen, since we tried creating a
@ -1285,7 +1285,7 @@ bool DirManager::EnsureSafeFilename(wxFileName fName)
ODDecodeBlockFile *db = (ODDecodeBlockFile*)b; ODDecodeBlockFile *db = (ODDecodeBlockFile*)b;
if (b->IsAlias() && ab->GetAliasedFile() == fName) if (b->IsAlias() && ab->GetAliasedFileName() == fName)
{ {
ab->UnlockRead(); ab->UnlockRead();
} }
@ -1298,7 +1298,7 @@ bool DirManager::EnsureSafeFilename(wxFileName fName)
// Print error message and cancel the export // Print error message and cancel the export
wxLogSysError(_("Unable to rename '%s' to '%s'"), wxLogSysError(_("Unable to rename '%s' to '%s'"),
fName.GetFullPath().c_str(), fName.GetFullPath().c_str(),
renamedFile.GetFullPath().c_str()); renamedFileName.GetFullPath().c_str());
return false; return false;
} }
else else
@ -1310,15 +1310,15 @@ bool DirManager::EnsureSafeFilename(wxFileName fName)
AliasBlockFile *ab = (AliasBlockFile*)b; AliasBlockFile *ab = (AliasBlockFile*)b;
ODDecodeBlockFile *db = (ODDecodeBlockFile*)b; ODDecodeBlockFile *db = (ODDecodeBlockFile*)b;
if (b->IsAlias() && ab->GetAliasedFile() == fName) if (b->IsAlias() && ab->GetAliasedFileName() == fName)
{ {
ab->ChangeAliasedFile(renamedFile); ab->ChangeAliasedFileName(renamedFileName);
ab->UnlockRead(); ab->UnlockRead();
wxPrintf(_("Changed block %s to new alias name\n"), b->GetFileName().GetFullName().c_str()); wxPrintf(_("Changed block %s to new alias name\n"), b->GetFileName().GetFullName().c_str());
} }
if (!b->IsDataAvailable() && db->GetEncodedAudioFilename() == fName) { if (!b->IsDataAvailable() && db->GetEncodedAudioFilename() == fName) {
db->ChangeAudioFile(renamedFile); db->ChangeAudioFile(renamedFileName);
db->UnlockRead(); db->UnlockRead();
} }
it++; it++;
@ -1327,7 +1327,7 @@ bool DirManager::EnsureSafeFilename(wxFileName fName)
} }
aliasList.Remove(fName.GetFullPath()); aliasList.Remove(fName.GetFullPath());
aliasList.Add(renamedFile.GetFullPath()); aliasList.Add(renamedFileName.GetFullPath());
} }
// Success!!! Either we successfully renamed the file, // Success!!! Either we successfully renamed the file,
@ -1414,7 +1414,7 @@ int DirManager::ProjectFSCK(bool forceerror, bool silentlycorrect, bool bIgnoreN
BlockFile *b=i->second; BlockFile *b=i->second;
if(b->IsAlias()){ if(b->IsAlias()){
wxFileName aliasfile=((AliasBlockFile *)b)->GetAliasedFile(); wxFileName aliasfile=((AliasBlockFile *)b)->GetAliasedFileName();
if(aliasfile.GetFullPath()!=wxEmptyString && !wxFileExists(aliasfile.GetFullPath())){ if(aliasfile.GetFullPath()!=wxEmptyString && !wxFileExists(aliasfile.GetFullPath())){
missingAliasList[key]=b; missingAliasList[key]=b;
missingAliasFiles[aliasfile.GetFullPath().c_str()]=0; // simply must be defined missingAliasFiles[aliasfile.GetFullPath().c_str()]=0; // simply must be defined
@ -1531,8 +1531,8 @@ int DirManager::ProjectFSCK(bool forceerror, bool silentlycorrect, bool bIgnoreN
_("Project check detected %d external audio file(s) ('aliased files') \ _("Project check detected %d external audio file(s) ('aliased files') \
\nare now missing. There is no way for Audacity to recover these \ \nare now missing. There is no way for Audacity to recover these \
\nfiles automatically. \ \nfiles automatically. \
\n\nIf you choose the last option below, you can try to find and \ \n\nIf you choose the second or third option below, you can try to \
\nrestore the missing files to their previous location."); \nfind and restore the missing files to their previous location.");
wxString msg; wxString msg;
msg.Printf(msgA, missingAliasFiles.size()); msg.Printf(msgA, missingAliasFiles.size());
@ -1552,18 +1552,31 @@ _("Project check detected %d external audio file(s) ('aliased files') \
//safe, we checked that it's an alias block file earlier //safe, we checked that it's an alias block file earlier
if(action==0){ if(action==0){
//vvvvv This is incorrect in several ways.
// It returns FSCKstatus_CHANGED, and that makes AudacityProject::OpenFile
// do a PushState, but the tracks lower on the stack are identical to
// these and already have lost the missing aliased filename,
// so Undo Project Repair does effectively nothing, and yet
// it isn't an Undo, because these blockfiles have empty aliasFileNames.
// Should actually replace these blocks with SilentBlockFiles, a la
// RemoveDependencies() (from Dependencies.*). (More to follow!)
// silence the blockfiles by yanking the filename // silence the blockfiles by yanking the filename
//vvvvv But this causes Check Dependencies to show "MISSING" with no filename.
//vvvvv Replace with actual SilentBlockFile, as that's what the user commanded.
//vvvvv Call RemoveDependencies (from Dependencies.*) instead?
wxFileName dummy; wxFileName dummy;
dummy.Clear(); dummy.Clear();
b->ChangeAliasedFile(dummy); b->ChangeAliasedFileName(dummy);
b->Recover(); b->Recover();
ret |= FSCKstatus_CHANGED; ret |= FSCKstatus_CHANGED;
}else if(action==1){ }else if(action==1){
// silence the log for this session // silence the log for this session
//vvvvv Should do more than that...! //vvvvv Note, then, that "temporarily replace with silence" is really not what's done.
// Also, doesn't change the waveform to silence.
// Should it do a PushState? If so, then why have this other option?
// Instead, get rid of this, make action 0 replace with SilentBlockFiles,
// so there's an Undo state with the bad alias files and another with SilentBlockFiles,
// so we can get back to the bad alias files state.
// We could even just get rid of the block files, but that might cause gaps,
// and would lose information about the lengths of those tracks. (More to follow!)
b->SilenceAliasLog(); b->SilenceAliasLog();
} }
i++; i++;

View File

@ -345,7 +345,7 @@ void AudacityProject::CreateMenusAndCommands()
AudioIONotBusyFlag | RedoAvailableFlag, AudioIONotBusyFlag | RedoAvailableFlag,
AudioIONotBusyFlag | RedoAvailableFlag); AudioIONotBusyFlag | RedoAvailableFlag);
ModifyUndoMenus(); ModifyUndoMenuItems();
c->AddSeparator(); c->AddSeparator();
@ -1219,7 +1219,7 @@ void AudacityProject::CreateRecentFilesMenu(CommandManager *c)
} }
void AudacityProject::ModifyUndoMenus() void AudacityProject::ModifyUndoMenuItems()
{ {
wxString desc; wxString desc;
int cur = mUndoManager.GetCurrentState(); int cur = mUndoManager.GetCurrentState();
@ -3014,7 +3014,7 @@ void AudacityProject::OnUndo()
if (mHistoryWindow) if (mHistoryWindow)
mHistoryWindow->UpdateDisplay(); mHistoryWindow->UpdateDisplay();
ModifyUndoMenus(); ModifyUndoMenuItems();
} }
void AudacityProject::OnRedo() void AudacityProject::OnRedo()
@ -3035,7 +3035,7 @@ void AudacityProject::OnRedo()
if (mHistoryWindow) if (mHistoryWindow)
mHistoryWindow->UpdateDisplay(); mHistoryWindow->UpdateDisplay();
ModifyUndoMenus(); ModifyUndoMenuItems();
} }
void AudacityProject::OnCut() void AudacityProject::OnCut()
@ -5322,10 +5322,10 @@ void AudacityProject::OnApplyChain()
BatchProcessDialog d(this); BatchProcessDialog d(this);
d.ShowModal(); d.ShowModal();
// LL: See comments in ModifyUndoMenus() for info about this... // LL: See comments in ModifyUndoMenuItems() for info about this...
// //
// Refresh the Undo menu. // Refresh the Undo menu.
ModifyUndoMenus(); ModifyUndoMenuItems();
} }
void AudacityProject::OnEditChains() void AudacityProject::OnEditChains()

View File

@ -35,7 +35,7 @@ void AddEffectsToMenu(CommandManager* c, const EffectSet& effects);
#endif #endif
void CreateRecentFilesMenu(CommandManager *c); void CreateRecentFilesMenu(CommandManager *c);
void ModifyUndoMenus(); void ModifyUndoMenuItems();
void ModifyToolbarMenus(); void ModifyToolbarMenus();
// Calls ModifyToolbarMenus() on all projects // Calls ModifyToolbarMenus() on all projects
void ModifyAllProjectToolbarMenus(); void ModifyAllProjectToolbarMenus();

View File

@ -2465,22 +2465,24 @@ void AudacityProject::OpenFile(wxString fileName, bool addtohistory)
SetProjectTitle(); SetProjectTitle();
mTrackPanel->Refresh(true); mTrackPanel->Refresh(true);
}else if (status & FSCKstatus_CHANGED){ }
else if (status & FSCKstatus_CHANGED)
{
t = iter.First(); t = iter.First();
while (t) { while (t) {
if (t->GetKind() == Track::Wave) if (t->GetKind() == Track::Wave)
{ {
// Only wave tracks have a notion of "changed" // Only wave tracks have a notion of "changed"
for (WaveClipList::compatibility_iterator it=((WaveTrack*)t)->GetClipIterator(); it; it=it->GetNext()) for (WaveClipList::compatibility_iterator it=((WaveTrack*)t)->GetClipIterator();
it; it=it->GetNext())
it->GetData()->MarkChanged(); it->GetData()->MarkChanged();
} }
t = iter.Next(); t = iter.Next();
} }
mTrackPanel->Refresh(true); mTrackPanel->Refresh(true);
this->PushState(_("Project checker repaired file"), _("Repair")); this->PushState(_("Project checker repaired file"), _("Project Repair"));
}
}
} }
} else { } else {
mTracks->Clear(true); mTracks->Clear(true);
@ -3479,7 +3481,7 @@ void AudacityProject::InitialState()
if (mHistoryWindow) if (mHistoryWindow)
mHistoryWindow->UpdateDisplay(); mHistoryWindow->UpdateDisplay();
ModifyUndoMenus(); ModifyUndoMenuItems();
UpdateMenus(); UpdateMenus();
this->UpdateLyrics(); this->UpdateLyrics();
@ -3498,7 +3500,7 @@ void AudacityProject::PushState(wxString desc,
if (mHistoryWindow) if (mHistoryWindow)
mHistoryWindow->UpdateDisplay(); mHistoryWindow->UpdateDisplay();
ModifyUndoMenus(); ModifyUndoMenuItems();
UpdateMenus(); UpdateMenus();
@ -3587,7 +3589,7 @@ void AudacityProject::SetStateTo(unsigned int n)
HandleResize(); HandleResize();
mTrackPanel->SetFocusedTrack(NULL); mTrackPanel->SetFocusedTrack(NULL);
mTrackPanel->Refresh(false); mTrackPanel->Refresh(false);
ModifyUndoMenus(); ModifyUndoMenuItems();
this->UpdateLyrics(); this->UpdateLyrics();
this->UpdateMixerBoard(); this->UpdateMixerBoard();
} }