34{
35#pragma message( "====================================================================")
36#pragma message( "Don\'t forget to redo ProjectFSCK")
37#pragma message( "====================================================================")
38
39
40
41
42
43
44
45
46
47 int action;
48 int nResult = 0;
49
50 if (bForceError && !bAutoRecoverMode)
51 {
52
53
54
55
56
57
58 auto msg =
XO(
"Project check read faulty Sequence tags.");
60 XO(
"Close project immediately with no changes"),
61 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.")
62 };
63 wxLog::FlushActive();
65 XO(
"Warning - Problems Reading Sequence Tags"),
66 buttons,"");
67 if (action == 0)
69 else
71 }
72#if 0
74 auto dirPath = ( dm.GetDataFilesDir() );
75 DirManager::RecursivelyEnumerateWithProgress(
76 dirPath,
77 filePathArray,
78 wxEmptyString,
79 wxEmptyString,
80 true, false,
81 dm.NumBlockFiles(),
82 XO(
"Inspecting project file data"));
83
84
85
86
87 MissingAliasFilesDialog::SetShouldShow(false);
90 dm.FindMissingAliasFiles(missingAliasFilesAUFHash, missingAliasFilesPathHash);
91
93 {
94
95
96 if (bAutoRecoverMode)
97 action = 2;
98 else
99 {
100 auto msg =
101XO(
"Project check of \"%s\" folder \
102\ndetected %lld missing external audio file(s) \
103\n('aliased files'). There is no way for Audacity \
104\nto recover these files automatically. \
105\n\nIf you choose the first or second option below, \
106\nyou can try to find and restore the missing files \
107\nto their previous location. \
108\n\nNote that for the second option, the waveform \
109\nmay not show silence. \
110\n\nIf you choose the third option, this will save the \
111\nproject in its current state, unless you \"Close \
112\nproject immediately\" on further error alerts.")
113 .Format(
114 dm.GetProjectName(),
115 (long long) missingAliasFilesPathHash.size() );
117 XO(
"Close project immediately with no changes"),
118 XO(
"Treat missing audio as silence (this session only)"),
119 XO(
"Replace missing audio with silence (permanent immediately)."),
120 };
121 wxLog::FlushActive();
123 XO(
"Warning - Missing Aliased File(s)"),
124 buttons,
125 "");
126 }
127
128 if (action == 0)
130 else
131 {
132
133 BlockHash::iterator iter = missingAliasFilesAUFHash.begin();
134 while (iter != missingAliasFilesAUFHash.end())
135 {
136
137 BlockFilePtr b = iter->second.lock();
138 wxASSERT(b);
139 if (b) {
140 auto ab = static_cast< AliasBlockFile * > ( &*b );
141
142 if (action == 2)
143 {
144
145
146
147
149 dummy.Clear();
150 ab->ChangeAliasedFileName(std::move(dummy));
151
152
153
154
155
157 [&] { ab->Recover(); },
159 );
160
162 }
163
164 if (action == 1)
165
166 ab->SilenceAliasLog();
167 }
168 ++iter;
169 }
170 if ((action == 2) && bAutoRecoverMode)
171 wxLogWarning(
wxT(
" Project check replaced missing aliased file(s) with silence."));
172 }
173 }
174
175
176
177
178
179
181 dm.FindMissingAUFs(missingAUFHash);
183 {
184
185
186 if (bAutoRecoverMode)
187 action = 0;
188 else
189 {
190 auto msg =
191XO(
"Project check of \"%s\" folder \
192\ndetected %lld missing alias (.auf) blockfile(s). \
193\nAudacity can fully regenerate these files \
194\nfrom the current audio in the project.")
195 .Format(
196 dm.GetProjectName(), (long long) missingAUFHash.size() );
198 XO(
"Regenerate alias summary files (safe and recommended)"),
199 XO(
"Fill in silence for missing display data (this session only)"),
200 XO(
"Close project immediately with no further changes"),
201 };
202 wxLog::FlushActive();
204 XO(
"Warning - Missing Alias Summary File(s)"),
205 buttons,
206 "");
207 }
208
209 if (action == 2)
211 else
212 {
213
214 BlockHash::iterator iter = missingAUFHash.begin();
215 while (iter != missingAUFHash.end())
216 {
217 BlockFilePtr b = iter->second.lock();
218 wxASSERT(b);
219 if (b) {
220 if(action==0) {
221
222
223
224
225
227 [&] {
228 b->Recover();
230 },
232 );
233 }
234
235 if (action==1){
236
237 b->SilenceLog();
238 }
239 }
240 ++iter;
241 }
242 if ((action == 0) && bAutoRecoverMode)
243 wxLogWarning(
wxT(
" Project check regenerated missing alias summary file(s)."));
244 }
245 }
246
247
248
249
251 dm.FindMissingAUs(missingAUHash);
253 {
254
255
256 if (bAutoRecoverMode)
257 action = 2;
258 else
259 {
260 auto msg =
261XO(
"Project check of \"%s\" folder \
262\ndetected %lld missing audio data (.au) blockfile(s), \
263\nprobably due to a bug, system crash, or accidental \
264\ndeletion. There is no way for Audacity to recover \
265\nthese missing files automatically. \
266\n\nIf you choose the first or second option below, \
267\nyou can try to find and restore the missing files \
268\nto their previous location. \
269\n\nNote that for the second option, the waveform \
270\nmay not show silence.")
271 .Format(
272 dm.GetProjectName(), (long long) missingAUHash.size() );
274 XO(
"Close project immediately with no further changes"),
275 XO(
"Treat missing audio as silence (this session only)"),
276 XO(
"Replace missing audio with silence (permanent immediately)"),
277 };
278 wxLog::FlushActive();
280 XO(
"Warning - Missing Audio Data Block File(s)"),
281 buttons,
282 "Warning_-_Missing_Audio_Data_Block_Files");
283 }
284
285 if (action == 0)
287 else
288 {
289
290 BlockHash::iterator iter = missingAUHash.begin();
291 while (iter != missingAUHash.end())
292 {
293 BlockFilePtr b = iter->second.lock();
294 wxASSERT(b);
295 if (b) {
296 if (action == 2)
297 {
298
299
300
301
302
304 [&] {
305
306 b->Recover();
308 },
310 );
311 }
312
313 if (action == 1)
314 b->SilenceLog();
315 }
316 ++iter;
317 }
318 if ((action == 2) && bAutoRecoverMode)
319 wxLogWarning(
wxT(
" Project check replaced missing audio data block file(s) with silence."));
320 }
321 }
322
323
324
325
327 dm.FindOrphanBlockFiles(filePathArray, orphanFilePathArray);
328
330 {
331
332
333 if (bAutoRecoverMode)
334 {
335 wxLogWarning(
wxT(
" Project check ignored orphan block file(s). They will be deleted when project is saved."));
336 action = 1;
337 }
338 else
339 {
340 auto msg =
341XO(
"Project check of \"%s\" folder \
342\nfound %d orphan block file(s). These files are \
343\nunused by this project, but might belong to \
344other projects. \
345\nThey are doing no harm and are small.")
346 .Format( dm.GetProjectName(), (int)orphanFilePathArray.size() );
347
349 XO(
"Continue without deleting; ignore the extra files this session"),
350 XO(
"Close project immediately with no further changes"),
351 XO(
"Delete orphan files (permanent immediately)"),
352 };
353 wxLog::FlushActive();
355 XO(
"Warning - Orphan Block File(s)"),
356 buttons,
357 "Warning_-_Orphan_Block_Files"
358 );
359 }
360
361 if (action == 1)
363
364 else if (action == 2)
365 {
366
367
368
369
370
371 for ( const auto &orphan : orphanFilePathArray )
372 wxRemoveFile(orphan);
373 }
374 }
375
377 {
378
381 XO(
"Cleaning up unused directories in project data"));
382
383 int nDirCount = DirManager::RecursivelyCountSubdirs(dirPath) + 1;
384 DirManager::RecursivelyRemoveEmptyDirs(dirPath, nDirCount, &pProgress);
385 }
386
387
388 if (bForceError ||
389 !missingAliasFilesAUFHash.empty() ||
390 !missingAUFHash.empty() ||
391 !missingAUHash.empty() ||
392 !orphanFilePathArray.empty())
393 {
394 wxLogWarning(
wxT(
"Project check found file inconsistencies inspecting the loaded project data."));
395 wxLog::FlushActive();
396
397
398 if (bAutoRecoverMode)
401"Project check found file inconsistencies during automatic recovery.\n\nSelect 'Help > Diagnostics > Show Log...' to see details."),
402 XO(
"Warning: Problems in Automatic Recovery"),
403 wxOK | wxICON_EXCLAMATION);
404 }
405
406 MissingAliasFilesDialog::SetShouldShow(true);
407#endif
408 return nResult;
409}
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)
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.
int ShowMultiDialog(const TranslatableString &message, const TranslatableString &title, const TranslatableStrings &buttons, const ManualPageID &helpPage, const TranslatableString &boxMsg, bool log)
Display a dialog with radio buttons.