19#include "DirManager.h"
34 DirManager &dm,
const bool bForceError,
const bool bAutoRecoverMode)
36#pragma message( "====================================================================")
37#pragma message( "Don\'t forget to redo ProjectFSCK")
38#pragma message( "====================================================================")
51 if (bForceError && !bAutoRecoverMode)
59 auto msg =
XO(
"Project check read faulty Sequence tags.");
61 XO(
"Close project immediately with no changes"),
62 XO(
"Continue with repairs noted in log, and check for more errors. This will save the project in its current state, unless you \"Close project immediately\" on further error alerts.")
66 XO(
"Warning - Problems Reading Sequence Tags"),
75 auto dirPath = ( dm.GetDataFilesDir() );
76 DirManager::RecursivelyEnumerateWithProgress(
83 XO(
"Inspecting project file data"));
88 MissingAliasFilesDialog::SetShouldShow(
false);
89 BlockHash missingAliasFilesAUFHash;
90 BlockHash missingAliasFilesPathHash;
91 dm.FindMissingAliasFiles(missingAliasFilesAUFHash, missingAliasFilesPathHash);
102XO(
"Project check of \"%s\" folder \
103\ndetected %lld missing external audio file(s) \
104\n('aliased files'). There is no way for Audacity \
105\nto recover these files automatically. \
106\n\nIf you choose the first or second option below, \
107\nyou can try to find and restore the missing files \
108\nto their previous location. \
109\n\nNote that for the second option, the waveform \
110\nmay not show silence. \
111\n\nIf you choose the third option, this will save the \
112\nproject in its current state, unless you \"Close \
113\nproject immediately\" on further error alerts.")
116 (
long long) missingAliasFilesPathHash.size() );
118 XO(
"Close project immediately with no changes"),
119 XO(
"Treat missing audio as silence (this session only)"),
120 XO(
"Replace missing audio with silence (permanent immediately)."),
122 wxLog::FlushActive();
124 XO(
"Warning - Missing Aliased File(s)"),
134 BlockHash::iterator iter = missingAliasFilesAUFHash.begin();
135 while (iter != missingAliasFilesAUFHash.end())
138 BlockFilePtr b = iter->second.lock();
141 auto ab =
static_cast< AliasBlockFile *
> ( &*b );
151 ab->ChangeAliasedFileName(std::move(dummy));
158 [&] { ab->Recover(); },
167 ab->SilenceAliasLog();
171 if ((action == 2) && bAutoRecoverMode)
172 wxLogWarning(wxT(
" Project check replaced missing aliased file(s) with silence."));
181 BlockHash missingAUFHash;
182 dm.FindMissingAUFs(missingAUFHash);
187 if (bAutoRecoverMode)
192XO(
"Project check of \"%s\" folder \
193\ndetected %lld missing alias (.auf) blockfile(s). \
194\nAudacity can fully regenerate these files \
195\nfrom the current audio in the project.")
197 dm.GetProjectName(), (
long long) missingAUFHash.size() );
199 XO(
"Regenerate alias summary files (safe and recommended)"),
200 XO(
"Fill in silence for missing display data (this session only)"),
201 XO(
"Close project immediately with no further changes"),
203 wxLog::FlushActive();
205 XO(
"Warning - Missing Alias Summary File(s)"),
215 BlockHash::iterator iter = missingAUFHash.begin();
216 while (iter != missingAUFHash.end())
218 BlockFilePtr b = iter->second.lock();
243 if ((action == 0) && bAutoRecoverMode)
244 wxLogWarning(wxT(
" Project check regenerated missing alias summary file(s)."));
251 BlockHash missingAUHash;
252 dm.FindMissingAUs(missingAUHash);
257 if (bAutoRecoverMode)
262XO(
"Project check of \"%s\" folder \
263\ndetected %lld missing audio data (.au) blockfile(s), \
264\nprobably due to a bug, system crash, or accidental \
265\ndeletion. There is no way for Audacity to recover \
266\nthese missing files automatically. \
267\n\nIf you choose the first or second option below, \
268\nyou can try to find and restore the missing files \
269\nto their previous location. \
270\n\nNote that for the second option, the waveform \
271\nmay not show silence.")
273 dm.GetProjectName(), (
long long) missingAUHash.size() );
275 XO(
"Close project immediately with no further changes"),
276 XO(
"Treat missing audio as silence (this session only)"),
277 XO(
"Replace missing audio with silence (permanent immediately)"),
279 wxLog::FlushActive();
281 XO(
"Warning - Missing Audio Data Block File(s)"),
283 "Warning_-_Missing_Audio_Data_Block_Files");
291 BlockHash::iterator iter = missingAUHash.begin();
292 while (iter != missingAUHash.end())
294 BlockFilePtr b = iter->second.lock();
319 if ((action == 2) && bAutoRecoverMode)
320 wxLogWarning(wxT(
" Project check replaced missing audio data block file(s) with silence."));
328 dm.FindOrphanBlockFiles(filePathArray, orphanFilePathArray);
334 if (bAutoRecoverMode)
336 wxLogWarning(wxT(
" Project check ignored orphan block file(s). They will be deleted when project is saved."));
342XO(
"Project check of \"%s\" folder \
343\nfound %d orphan block file(s). These files are \
344\nunused by this project, but might belong to \
346\nThey are doing no harm and are small.")
347 .Format( dm.GetProjectName(), (
int)orphanFilePathArray.size() );
350 XO(
"Continue without deleting; ignore the extra files this session"),
351 XO(
"Close project immediately with no further changes"),
352 XO(
"Delete orphan files (permanent immediately)"),
354 wxLog::FlushActive();
356 XO(
"Warning - Orphan Block File(s)"),
358 "Warning_-_Orphan_Block_Files"
365 else if (action == 2)
372 for (
const auto &orphan : orphanFilePathArray )
373 wxRemoveFile(orphan);
382 XO(
"Cleaning up unused directories in project data"));
384 int nDirCount = DirManager::RecursivelyCountSubdirs(dirPath) + 1;
385 DirManager::RecursivelyRemoveEmptyDirs(dirPath, nDirCount, &pProgress);
390 !missingAliasFilesAUFHash.empty() ||
391 !missingAUFHash.empty() ||
392 !missingAUHash.empty() ||
393 !orphanFilePathArray.empty())
395 wxLogWarning(wxT(
"Project check found file inconsistencies inspecting the loaded project data."));
396 wxLog::FlushActive();
399 if (bAutoRecoverMode)
402"Project check found file inconsistencies during automatic recovery.\n\nSelect 'Help > Diagnostics > Show Log...' to see details."),
403 XO(
"Warning: Problems in Automatic Recovery"),
404 wxOK | wxICON_EXCLAMATION);
407 MissingAliasFilesDialog::SetShouldShow(
true);
R GuardedCall(const F1 &body, const F2 &handler=F2::Default(), F3 delayedHandler=DefaultDelayedHandlerAction) noexcept(noexcept(handler(std::declval< AudacityException * >())) &&noexcept(handler(nullptr)) &&noexcept(std::function< void(AudacityException *)>{std::move(delayedHandler)}))
Execute some code on any thread; catch any AudacityException; enqueue error report on the main thread...
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
int ShowMultiDialog(const TranslatableString &message, const TranslatableString &title, const TranslatableStrings &buttons, const ManualPageID &helpPage, const TranslatableString &boxMsg, bool log)
int ProjectFSCK(DirManager &dm, const bool bForceError, const bool bAutoRecoverMode)
std::vector< TranslatableString > TranslatableStrings
Base class for exceptions specially processed by the application.
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.