Bug fix #364 - app was crashing on attempt to download PDF to which the user no longer had ownership. Eg: returned or Plus catalog
This commit is contained in:
parent
f05465b29b
commit
f310d583d8
@ -2,7 +2,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<Version>8.4.3.1</Version>
|
<Version>8.4.4.1</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Octokit" Version="2.0.0" />
|
<PackageReference Include="Octokit" Version="2.0.0" />
|
||||||
|
|||||||
@ -24,7 +24,7 @@ namespace FileLiberator
|
|||||||
{
|
{
|
||||||
OnBegin(libraryBook);
|
OnBegin(libraryBook);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var proposedDownloadFilePath = getProposedDownloadFilePath(libraryBook);
|
var proposedDownloadFilePath = getProposedDownloadFilePath(libraryBook);
|
||||||
var actualDownloadedFilePath = await downloadPdfAsync(libraryBook, proposedDownloadFilePath);
|
var actualDownloadedFilePath = await downloadPdfAsync(libraryBook, proposedDownloadFilePath);
|
||||||
@ -32,13 +32,22 @@ namespace FileLiberator
|
|||||||
|
|
||||||
libraryBook.Book.UpdatePdfStatus(result.IsSuccess ? LiberatedStatus.Liberated : LiberatedStatus.NotLiberated);
|
libraryBook.Book.UpdatePdfStatus(result.IsSuccess ? LiberatedStatus.Liberated : LiberatedStatus.NotLiberated);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Serilog.Log.Logger.Error(ex, "Error downloading PDF");
|
||||||
|
|
||||||
|
var result = new StatusHandler();
|
||||||
|
result.AddError($"Error downloading PDF. See log for details. Error summary: {ex.Message}");
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
OnCompleted(libraryBook);
|
OnCompleted(libraryBook);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string getProposedDownloadFilePath(LibraryBook libraryBook)
|
private static string getProposedDownloadFilePath(LibraryBook libraryBook)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -7,6 +7,7 @@ using Avalonia.Media;
|
|||||||
using Avalonia.Media.Imaging;
|
using Avalonia.Media.Imaging;
|
||||||
using DataLayer;
|
using DataLayer;
|
||||||
using Dinah.Core;
|
using Dinah.Core;
|
||||||
|
using Dinah.Core.ErrorHandling;
|
||||||
using FileLiberator;
|
using FileLiberator;
|
||||||
using LibationFileManager;
|
using LibationFileManager;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
@ -289,25 +290,36 @@ namespace LibationAvalonia.ViewModels
|
|||||||
Logger.Info($"{((Processable)sender).Name} Step, Completed: {libraryBook.Book}");
|
Logger.Info($"{((Processable)sender).Name} Step, Completed: {libraryBook.Book}");
|
||||||
UnlinkProcessable((Processable)sender);
|
UnlinkProcessable((Processable)sender);
|
||||||
|
|
||||||
if (Processes.Count > 0)
|
if (Processes.Count == 0)
|
||||||
{
|
{
|
||||||
NextProcessable();
|
Completed?.Invoke(this, EventArgs.Empty);
|
||||||
LinkProcessable(CurrentProcessable);
|
return;
|
||||||
var result = await CurrentProcessable.ProcessSingleAsync(libraryBook, validate: true);
|
}
|
||||||
|
|
||||||
if (result.HasErrors)
|
NextProcessable();
|
||||||
{
|
LinkProcessable(CurrentProcessable);
|
||||||
foreach (var errorMessage in result.Errors.Where(e => e != "Validation failed"))
|
|
||||||
Logger.Error(errorMessage);
|
|
||||||
|
|
||||||
Completed?.Invoke(this, EventArgs.Empty);
|
StatusHandler result;
|
||||||
}
|
try
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
Completed?.Invoke(this, EventArgs.Empty);
|
result = await CurrentProcessable.ProcessSingleAsync(libraryBook, validate: true);
|
||||||
}
|
}
|
||||||
}
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Serilog.Log.Logger.Error(ex, $"{nameof(Processable_Completed)} error");
|
||||||
|
|
||||||
|
result = new StatusHandler();
|
||||||
|
result.AddError($"{nameof(Processable_Completed)} error. See log for details. Error summary: {ex.Message}");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.HasErrors)
|
||||||
|
{
|
||||||
|
foreach (var errorMessage in result.Errors.Where(e => e != "Validation failed"))
|
||||||
|
Logger.Error(errorMessage);
|
||||||
|
|
||||||
|
Completed?.Invoke(this, EventArgs.Empty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,7 @@ using System.Windows.Forms;
|
|||||||
using ApplicationServices;
|
using ApplicationServices;
|
||||||
using DataLayer;
|
using DataLayer;
|
||||||
using Dinah.Core;
|
using Dinah.Core;
|
||||||
|
using Dinah.Core.ErrorHandling;
|
||||||
using Dinah.Core.WindowsDesktop.Drawing;
|
using Dinah.Core.WindowsDesktop.Drawing;
|
||||||
using FileLiberator;
|
using FileLiberator;
|
||||||
using LibationFileManager;
|
using LibationFileManager;
|
||||||
@ -279,36 +280,47 @@ namespace LibationWinForms.ProcessQueue
|
|||||||
updateBookInfo();
|
updateBookInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void Processable_Completed(object sender, LibraryBook libraryBook)
|
private async void Processable_Completed(object sender, LibraryBook libraryBook)
|
||||||
{
|
{
|
||||||
Logger.Info($"{((Processable)sender).Name} Step, Completed: {libraryBook.Book}");
|
Logger.Info($"{((Processable)sender).Name} Step, Completed: {libraryBook.Book}");
|
||||||
UnlinkProcessable((Processable)sender);
|
UnlinkProcessable((Processable)sender);
|
||||||
|
|
||||||
if (Processes.Count > 0)
|
if (Processes.Count == 0)
|
||||||
{
|
{
|
||||||
NextProcessable();
|
Completed?.Invoke(this, EventArgs.Empty);
|
||||||
LinkProcessable(CurrentProcessable);
|
return;
|
||||||
var result = await CurrentProcessable.ProcessSingleAsync(libraryBook, validate: true);
|
}
|
||||||
|
|
||||||
if (result.HasErrors)
|
NextProcessable();
|
||||||
{
|
LinkProcessable(CurrentProcessable);
|
||||||
foreach (var errorMessage in result.Errors.Where(e => e != "Validation failed"))
|
|
||||||
Logger.Error(errorMessage);
|
|
||||||
|
|
||||||
Completed?.Invoke(this, EventArgs.Empty);
|
StatusHandler result;
|
||||||
}
|
try
|
||||||
}
|
{
|
||||||
else
|
result = await CurrentProcessable.ProcessSingleAsync(libraryBook, validate: true);
|
||||||
{
|
}
|
||||||
Completed?.Invoke(this, EventArgs.Empty);
|
catch (Exception ex)
|
||||||
}
|
{
|
||||||
}
|
Serilog.Log.Logger.Error(ex, $"{nameof(Processable_Completed)} error");
|
||||||
|
|
||||||
#endregion
|
result = new StatusHandler();
|
||||||
|
result.AddError($"{nameof(Processable_Completed)} error. See log for details. Error summary: {ex.Message}");
|
||||||
|
}
|
||||||
|
|
||||||
#region Failure Handler
|
if (result.HasErrors)
|
||||||
|
{
|
||||||
|
foreach (var errorMessage in result.Errors.Where(e => e != "Validation failed"))
|
||||||
|
Logger.Error(errorMessage);
|
||||||
|
|
||||||
private ProcessBookResult showRetry(LibraryBook libraryBook)
|
Completed?.Invoke(this, EventArgs.Empty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Failure Handler
|
||||||
|
|
||||||
|
private ProcessBookResult showRetry(LibraryBook libraryBook)
|
||||||
{
|
{
|
||||||
Logger.Error("ERROR. All books have not been processed. Most recent book: processing failed");
|
Logger.Error("ERROR. All books have not been processed. Most recent book: processing failed");
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user