Bug fix: after successful pdf download, this state wasn't being saved
This commit is contained in:
parent
3eda498a5e
commit
9a4903f0dd
@ -175,7 +175,6 @@ namespace FileLiberator
|
|||||||
File.Move(f.FullName, dest);
|
File.Move(f.FullName, dest);
|
||||||
|
|
||||||
movedAudioFile |= AudibleFileStorage.Audio.IsFileTypeMatch(f);
|
movedAudioFile |= AudibleFileStorage.Audio.IsFileTypeMatch(f);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AudibleFileStorage.Audio.Refresh();
|
AudibleFileStorage.Audio.Refresh();
|
||||||
|
|||||||
@ -20,8 +20,8 @@ namespace FileLiberator
|
|||||||
public override async Task<StatusHandler> ProcessItemAsync(LibraryBook libraryBook)
|
public override async Task<StatusHandler> ProcessItemAsync(LibraryBook libraryBook)
|
||||||
{
|
{
|
||||||
var proposedDownloadFilePath = getProposedDownloadFilePath(libraryBook);
|
var proposedDownloadFilePath = getProposedDownloadFilePath(libraryBook);
|
||||||
await downloadPdfAsync(libraryBook, proposedDownloadFilePath);
|
var actualDownloadedFilePath = await downloadPdfAsync(libraryBook, proposedDownloadFilePath);
|
||||||
var result = verifyDownload(libraryBook);
|
var result = verifyDownload(actualDownloadedFilePath);
|
||||||
|
|
||||||
libraryBook.Book.UserDefinedItem.PdfStatus = result.IsSuccess ? LiberatedStatus.Liberated : LiberatedStatus.NotLiberated;
|
libraryBook.Book.UserDefinedItem.PdfStatus = result.IsSuccess ? LiberatedStatus.Liberated : LiberatedStatus.NotLiberated;
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ namespace FileLiberator
|
|||||||
private static string getdownloadUrl(LibraryBook libraryBook)
|
private static string getdownloadUrl(LibraryBook libraryBook)
|
||||||
=> libraryBook?.Book?.Supplements?.FirstOrDefault()?.Url;
|
=> libraryBook?.Book?.Supplements?.FirstOrDefault()?.Url;
|
||||||
|
|
||||||
private async Task downloadPdfAsync(LibraryBook libraryBook, string proposedDownloadFilePath)
|
private async Task<string> downloadPdfAsync(LibraryBook libraryBook, string proposedDownloadFilePath)
|
||||||
{
|
{
|
||||||
var api = await GetApiAsync(libraryBook);
|
var api = await GetApiAsync(libraryBook);
|
||||||
var downloadUrl = await api.GetPdfDownloadLinkAsync(libraryBook.Book.AudibleProductId);
|
var downloadUrl = await api.GetPdfDownloadLinkAsync(libraryBook.Book.AudibleProductId);
|
||||||
@ -57,10 +57,12 @@ namespace FileLiberator
|
|||||||
var actualDownloadedFilePath = await PerformDownloadAsync(
|
var actualDownloadedFilePath = await PerformDownloadAsync(
|
||||||
proposedDownloadFilePath,
|
proposedDownloadFilePath,
|
||||||
(p) => client.DownloadFileAsync(downloadUrl, proposedDownloadFilePath, p));
|
(p) => client.DownloadFileAsync(downloadUrl, proposedDownloadFilePath, p));
|
||||||
|
|
||||||
|
return actualDownloadedFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static StatusHandler verifyDownload(LibraryBook libraryBook)
|
private static StatusHandler verifyDownload(string actualDownloadedFilePath)
|
||||||
=> !libraryBook.Book.PDF_Exists
|
=> !File.Exists(actualDownloadedFilePath)
|
||||||
? new StatusHandler { "Downloaded PDF cannot be found" }
|
? new StatusHandler { "Downloaded PDF cannot be found" }
|
||||||
: new StatusHandler();
|
: new StatusHandler();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
<!-- <PublishSingleFile>true</PublishSingleFile> -->
|
<!-- <PublishSingleFile>true</PublishSingleFile> -->
|
||||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
|
|
||||||
<Version>5.5.7.2</Version>
|
<Version>5.5.7.4</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
|||||||
@ -132,14 +132,15 @@ namespace LibationWinForms
|
|||||||
|
|
||||||
private void Commit()
|
private void Commit()
|
||||||
{
|
{
|
||||||
//We don't want LiberatedStatus.PartialDownload to be a persistent status.
|
// We don't want LiberatedStatus.PartialDownload to be a persistent status.
|
||||||
var bookStatus = Book.UserDefinedItem.BookStatus;
|
// If display/icon status is PartialDownload then save NotLiberated to db then restore PartialDownload for display
|
||||||
var saveStatus = bookStatus == LiberatedStatus.PartialDownload ? LiberatedStatus.NotLiberated : bookStatus;
|
var displayStatus = Book.UserDefinedItem.BookStatus;
|
||||||
|
var saveStatus = displayStatus == LiberatedStatus.PartialDownload ? LiberatedStatus.NotLiberated : displayStatus;
|
||||||
Book.UserDefinedItem.BookStatus = saveStatus;
|
Book.UserDefinedItem.BookStatus = saveStatus;
|
||||||
|
|
||||||
LibraryCommands.UpdateUserDefinedItem(Book);
|
LibraryCommands.UpdateUserDefinedItem(Book);
|
||||||
|
|
||||||
Book.UserDefinedItem.BookStatus = bookStatus;
|
Book.UserDefinedItem.BookStatus = displayStatus;
|
||||||
|
|
||||||
Refilter?.Invoke();
|
Refilter?.Invoke();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user