bug fix around latest skip-bad-book feature
This commit is contained in:
parent
cefab86ce1
commit
bc6f53c8ea
@ -78,11 +78,11 @@ namespace FileLiberator
|
|||||||
Dinah.Core.IO.FileExt.SafeDelete(aaxFilename);
|
Dinah.Core.IO.FileExt.SafeDelete(aaxFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
var statusHandler = new StatusHandler();
|
|
||||||
var finalAudioExists = AudibleFileStorage.Audio.Exists(libraryBook.Book.AudibleProductId);
|
var finalAudioExists = AudibleFileStorage.Audio.Exists(libraryBook.Book.AudibleProductId);
|
||||||
if (!finalAudioExists)
|
if (!finalAudioExists)
|
||||||
statusHandler.AddError("Cannot find final audio file after decryption");
|
return new StatusHandler { "Cannot find final audio file after decryption" };
|
||||||
return statusHandler;
|
|
||||||
|
return new StatusHandler();
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
<!-- <PublishSingleFile>true</PublishSingleFile> -->
|
<!-- <PublishSingleFile>true</PublishSingleFile> -->
|
||||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
|
|
||||||
<Version>4.1.7.1</Version>
|
<Version>4.1.8.1</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -334,6 +334,10 @@ namespace LibationWinForms.BookLiberation
|
|||||||
|
|
||||||
protected abstract Task RunAsync();
|
protected abstract Task RunAsync();
|
||||||
|
|
||||||
|
protected abstract string SkipDialogText { get; }
|
||||||
|
protected abstract MessageBoxButtons SkipDialogButtons { get; }
|
||||||
|
protected abstract DialogResult CreateSkipFileResult { get; }
|
||||||
|
|
||||||
public async Task RunBackupAsync()
|
public async Task RunBackupAsync()
|
||||||
{
|
{
|
||||||
AutomatedBackupsForm.Show();
|
AutomatedBackupsForm.Show();
|
||||||
@ -351,21 +355,31 @@ namespace LibationWinForms.BookLiberation
|
|||||||
LogMe.Info("DONE");
|
LogMe.Info("DONE");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract string SkipDialogText { get; }
|
protected async Task<bool> ProcessOneAsync(Func<LibraryBook, Task<StatusHandler>> func, LibraryBook libraryBook)
|
||||||
protected abstract MessageBoxButtons SkipDialogButtons { get; }
|
|
||||||
protected abstract DialogResult CreateSkipFileResult { get; }
|
|
||||||
|
|
||||||
protected bool ValidateStatusAsync(StatusHandler statusHandler, LibraryBook libraryBook)
|
|
||||||
{
|
{
|
||||||
if (!statusHandler.HasErrors)
|
string logMessage;
|
||||||
return true;
|
|
||||||
|
|
||||||
LogMe.Error("ERROR. All books have not been processed. Most recent valid book: processing failed");
|
|
||||||
foreach (var errorMessage in statusHandler.Errors)
|
|
||||||
LogMe.Error(errorMessage);
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var statusHandler = await func(libraryBook);
|
||||||
|
|
||||||
|
if (statusHandler.IsSuccess)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
foreach (var errorMessage in statusHandler.Errors)
|
||||||
|
LogMe.Error(errorMessage);
|
||||||
|
|
||||||
|
logMessage = statusHandler.Errors.Aggregate((a, b) => $"{a}\r\n{b}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
LogMe.Error(ex);
|
||||||
|
|
||||||
|
logMessage = ex.Message + "\r\n|\r\n" + ex.StackTrace;
|
||||||
|
}
|
||||||
|
|
||||||
|
LogMe.Error("ERROR. All books have not been processed. Most recent book: processing failed");
|
||||||
|
|
||||||
var dialogResult = MessageBox.Show(SkipDialogText, "Skip importing this book?", SkipDialogButtons, MessageBoxIcon.Question);
|
var dialogResult = MessageBox.Show(SkipDialogText, "Skip importing this book?", SkipDialogButtons, MessageBoxIcon.Question);
|
||||||
|
|
||||||
if (dialogResult == DialogResult.Abort)
|
if (dialogResult == DialogResult.Abort)
|
||||||
@ -373,12 +387,9 @@ namespace LibationWinForms.BookLiberation
|
|||||||
|
|
||||||
if (dialogResult == CreateSkipFileResult)
|
if (dialogResult == CreateSkipFileResult)
|
||||||
{
|
{
|
||||||
var path = FileManager.AudibleFileStorage.Audio.CreateSkipFile(
|
var path = FileManager.AudibleFileStorage.Audio.CreateSkipFile(libraryBook.Book.Title, libraryBook.Book.AudibleProductId, logMessage);
|
||||||
libraryBook.Book.Title,
|
|
||||||
libraryBook.Book.AudibleProductId,
|
|
||||||
statusHandler.Errors.Aggregate((a, b) => $"{a}\r\n{b}"));
|
|
||||||
LogMe.Info($@"
|
LogMe.Info($@"
|
||||||
Created new skip file
|
Created new 'skip' file
|
||||||
[{libraryBook.Book.AudibleProductId}] {libraryBook.Book.Title}
|
[{libraryBook.Book.AudibleProductId}] {libraryBook.Book.Title}
|
||||||
{path}
|
{path}
|
||||||
".Trim());
|
".Trim());
|
||||||
@ -386,12 +397,6 @@ Created new skip file
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
LogMe.Error(ex, "Error attempting to display skip option box");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
class BackupSingle : BackupRunner
|
class BackupSingle : BackupRunner
|
||||||
{
|
{
|
||||||
@ -415,11 +420,8 @@ An error occurred while trying to process this book. Skip this book permanently?
|
|||||||
|
|
||||||
protected override async Task RunAsync()
|
protected override async Task RunAsync()
|
||||||
{
|
{
|
||||||
if (_libraryBook is null)
|
if (_libraryBook is not null)
|
||||||
return;
|
await ProcessOneAsync(Processable.ProcessSingleAsync, _libraryBook);
|
||||||
|
|
||||||
var statusHandler = await Processable.ProcessSingleAsync(_libraryBook);
|
|
||||||
ValidateStatusAsync(statusHandler, _libraryBook);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class BackupLoop : BackupRunner
|
class BackupLoop : BackupRunner
|
||||||
@ -444,11 +446,7 @@ An error occurred while trying to process this book
|
|||||||
// support for 'skip this time only' requires state. iterators provide this state for free. therefore: use foreach/iterator here
|
// support for 'skip this time only' requires state. iterators provide this state for free. therefore: use foreach/iterator here
|
||||||
foreach (var libraryBook in Processable.GetValidLibraryBooks())
|
foreach (var libraryBook in Processable.GetValidLibraryBooks())
|
||||||
{
|
{
|
||||||
try
|
var keepGoing = await ProcessOneAsync(Processable.ProcessBookAsync_NoValidation, libraryBook);
|
||||||
{
|
|
||||||
var statusHandler = await Processable.ProcessBookAsync_NoValidation(libraryBook);
|
|
||||||
|
|
||||||
var keepGoing = ValidateStatusAsync(statusHandler, libraryBook);
|
|
||||||
if (!keepGoing)
|
if (!keepGoing)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -459,11 +457,6 @@ An error occurred while trying to process this book
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception exc)
|
|
||||||
{
|
|
||||||
LogMe.Error(exc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LogMe.Info("Done. All books have been processed");
|
LogMe.Info("Done. All books have been processed");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user