From b9314ac678837e0e8236e80621540163f679e4cb Mon Sep 17 00:00:00 2001 From: Robert McRackan Date: Fri, 15 Nov 2019 22:43:04 -0500 Subject: [PATCH] Added validation and error handling BETA READY --- FileLiberator/UNTESTED/BackupBook.cs | 11 ++----- FileLiberator/UNTESTED/DownloadPdf.cs | 8 ++--- FileLiberator/UNTESTED/IProcessableExt.cs | 7 +++- LibationWinForm/LibationWinForm.csproj | 2 +- .../UNTESTED/Dialogs/IndexLibraryDialog.cs | 9 ++++- REFERENCE.txt | 6 ++-- __TODO.txt | 33 ++++++++++--------- 7 files changed, 42 insertions(+), 34 deletions(-) diff --git a/FileLiberator/UNTESTED/BackupBook.cs b/FileLiberator/UNTESTED/BackupBook.cs index e61dfc68..642e1f4d 100644 --- a/FileLiberator/UNTESTED/BackupBook.cs +++ b/FileLiberator/UNTESTED/BackupBook.cs @@ -43,19 +43,19 @@ namespace FileLiberator try { { - var statusHandler = await processAsync(libraryBook, AudibleFileStorage.AAX, DownloadBook); + var statusHandler = await DownloadBook.TryProcessAsync(libraryBook); if (statusHandler.HasErrors) return statusHandler; } { - var statusHandler = await processAsync(libraryBook, AudibleFileStorage.Audio, DecryptBook); + var statusHandler = await DecryptBook.TryProcessAsync(libraryBook); if (statusHandler.HasErrors) return statusHandler; } { - var statusHandler = await processAsync(libraryBook, AudibleFileStorage.PDF, DownloadPdf); + var statusHandler = await DownloadPdf.TryProcessAsync(libraryBook); if (statusHandler.HasErrors) return statusHandler; } @@ -67,10 +67,5 @@ namespace FileLiberator Completed?.Invoke(this, displayMessage); } } - - private static async Task processAsync(LibraryBook libraryBook, AudibleFileStorage afs, IProcessable processable) - => !await afs.ExistsAsync(libraryBook.Book.AudibleProductId) - ? await processable.ProcessAsync(libraryBook) - : new StatusHandler(); } } diff --git a/FileLiberator/UNTESTED/DownloadPdf.cs b/FileLiberator/UNTESTED/DownloadPdf.cs index 83eeadbc..d50403dd 100644 --- a/FileLiberator/UNTESTED/DownloadPdf.cs +++ b/FileLiberator/UNTESTED/DownloadPdf.cs @@ -13,12 +13,8 @@ namespace FileLiberator public class DownloadPdf : DownloadableBase { public override async Task ValidateAsync(LibraryBook libraryBook) - { - if (string.IsNullOrWhiteSpace(getdownloadUrl(libraryBook))) - return false; - - return !await AudibleFileStorage.PDF.ExistsAsync(libraryBook.Book.AudibleProductId); - } + => !string.IsNullOrWhiteSpace(getdownloadUrl(libraryBook)) + && !await AudibleFileStorage.PDF.ExistsAsync(libraryBook.Book.AudibleProductId); private static string getdownloadUrl(LibraryBook libraryBook) => libraryBook?.Book?.Supplements?.FirstOrDefault()?.Url; diff --git a/FileLiberator/UNTESTED/IProcessableExt.cs b/FileLiberator/UNTESTED/IProcessableExt.cs index c89991e1..8c0f165a 100644 --- a/FileLiberator/UNTESTED/IProcessableExt.cs +++ b/FileLiberator/UNTESTED/IProcessableExt.cs @@ -40,5 +40,10 @@ namespace FileLiberator return null; } - } + + public static async Task TryProcessAsync(this IProcessable processable, LibraryBook libraryBook) + => await processable.ValidateAsync(libraryBook) + ? await processable.ProcessAsync(libraryBook) + : new StatusHandler(); + } } diff --git a/LibationWinForm/LibationWinForm.csproj b/LibationWinForm/LibationWinForm.csproj index 6a009625..87bb120e 100644 --- a/LibationWinForm/LibationWinForm.csproj +++ b/LibationWinForm/LibationWinForm.csproj @@ -9,7 +9,7 @@ true true - true + win-x64 diff --git a/LibationWinForm/UNTESTED/Dialogs/IndexLibraryDialog.cs b/LibationWinForm/UNTESTED/Dialogs/IndexLibraryDialog.cs index ca48a098..6d7eaa2b 100644 --- a/LibationWinForm/UNTESTED/Dialogs/IndexLibraryDialog.cs +++ b/LibationWinForm/UNTESTED/Dialogs/IndexLibraryDialog.cs @@ -16,7 +16,14 @@ namespace LibationWinForm private async void IndexLibraryDialog_Shown(object sender, System.EventArgs e) { - (TotalBooksProcessed, NewBooksAdded) = await LibraryCommands.IndexLibraryAsync(new Login.WinformResponder()); + try + { + (TotalBooksProcessed, NewBooksAdded) = await LibraryCommands.IndexLibraryAsync(new Login.WinformResponder()); + } + catch + { + MessageBox.Show("Error importing library. Please try again. If this happens after 2 or 3 tries, contact administrator", "Error importing library", MessageBoxButtons.OK, MessageBoxIcon.Error); + } this.Close(); } diff --git a/REFERENCE.txt b/REFERENCE.txt index e9ff2a08..b342a752 100644 --- a/REFERENCE.txt +++ b/REFERENCE.txt @@ -1,15 +1,17 @@ -- begin VERSIONING --------------------------------------------------------------------------------------------------------------------- https://github.com/rmcrackan/Libation/releases -v3.0.3 : Switch to SQLite +v3.0.3 : Switch to SQLite. No longer relies on LocalDB, which must be installed separately v3.0.2 : Final using LocalDB v3.0.1 : Legacy inAudible wire-up code is still present but is commented out. All future check-ins are not guaranteed to have inAudible wire-up code v3.0 : This version is fully powered by the Audible API. Legacy scraping code is still present but is commented out. All future check-ins are not guaranteed to have any scraping code +v2 : new library page scraping. still chrome cookies. all decryption is handled natively. no inAudible dependency +v1 : old library ajax scraping. wish list scraping. chrome cookies. directly call local inAudible. .net framework -- end VERSIONING --------------------------------------------------------------------------------------------------------------------- -- begin HOW TO PUBLISH --------------------------------------------------------------------------------------------------------------------- OPTION 1: UI -rt-clk project > Publish... +rt-clk project project > Publish... click Publish OPTION 2: cmd line diff --git a/__TODO.txt b/__TODO.txt index 90e0da7f..53a19f40 100644 --- a/__TODO.txt +++ b/__TODO.txt @@ -1,24 +1,17 @@ -- begin BETA --------------------------------------------------------------------------------------------------------------------- -TESTING BUG -dbl clk. long pause. exception: -System.ComponentModel.Win32Exception (2): The system cannot find the file specified. -"continue" button allows me to keep using -bottom #s do not update -login succeeded. IdentityTokens.json successfully created -received above error again during scan. continue -stuck on scan. force quit from task manager -only files: - Images -- empty dir - IdentityTokens.json -- populated -no mdf, ldf - -REPLACE DB -need completely new db? replace LocalDb with sqlite? embedded document nosql (LiteDB)? +FINAL PRE-BETA TEST +create release + v3.1 beta + update REFERENCE.txt with this release +publish exe and attach it to the beta release +start beta: contact beta members CREATE INSTALLER see REFERENCE.txt > HOW TO PUBLISH RELEASE TO BETA +Note: run Libation.exe -- icon is a black wine glass +I recommend making a shortcut. I'm working on a more manageable install but it's low priority Warn of known performance issues - Library import - Tag add/edit @@ -27,6 +20,16 @@ Warn of known performance issues - images can take a bit to initially load. downloading is throttled as to not get the IP blocked by audible -- end BETA --------------------------------------------------------------------------------------------------------------------- +-- begin SINGLE FILE PUBLISH --------------------------------------------------------------------------------------------------------------------- +SINGLE FILE. FUTURE FIX + + true +Runs from weird temp location +- Weird default location for files +- Can’t find json +- don't have external exe.s +-- end SINGLE FILE PUBLISH --------------------------------------------------------------------------------------------------------------------- + -- begin ENHANCEMENT, IMPORT UI --------------------------------------------------------------------------------------------------------------------- scan library in background? can include a notice somewhere that a scan is in-process