From e971d3494886b8627269e469eb24dba628fc6555 Mon Sep 17 00:00:00 2001 From: Robert McRackan Date: Tue, 22 Sep 2020 15:43:13 -0400 Subject: [PATCH] Bug fix: downloading PDFs without also Liberating books -- post-download verification step was failing --- FileLiberator/UNTESTED/DownloadPdf.cs | 18 ++++++++++++------ LibationLauncher/LibationLauncher.csproj | 2 +- .../ProcessorAutomationController.cs | 6 ++++++ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/FileLiberator/UNTESTED/DownloadPdf.cs b/FileLiberator/UNTESTED/DownloadPdf.cs index 2a41f793..917d1de6 100644 --- a/FileLiberator/UNTESTED/DownloadPdf.cs +++ b/FileLiberator/UNTESTED/DownloadPdf.cs @@ -31,12 +31,18 @@ private static StatusHandler verifyDownload(LibraryBook libraryBook) private static string getProposedDownloadFilePath(LibraryBook libraryBook) { // if audio file exists, get it's dir. else return base Book dir - var destinationDir = - // this is safe b/c GetDirectoryName(null) == null - Path.GetDirectoryName(AudibleFileStorage.Audio.GetPath(libraryBook.Book.AudibleProductId)) - ?? AudibleFileStorage.PDF.StorageDirectory; - - return Path.Combine(destinationDir, Path.GetFileName(getdownloadUrl(libraryBook))); + var existingPath = Path.GetDirectoryName(AudibleFileStorage.Audio.GetPath(libraryBook.Book.AudibleProductId)); + var file = getdownloadUrl(libraryBook); + + if (existingPath != null) + return Path.Combine(existingPath, Path.GetFileName(file)); + + var full = FileUtility.GetValidFilename( + AudibleFileStorage.PDF.StorageDirectory, + libraryBook.Book.Title, + Path.GetExtension(file), + libraryBook.Book.AudibleProductId); + return full; } private async Task downloadPdfAsync(LibraryBook libraryBook, string proposedDownloadFilePath) diff --git a/LibationLauncher/LibationLauncher.csproj b/LibationLauncher/LibationLauncher.csproj index 9702bd61..7c3cb9f0 100644 --- a/LibationLauncher/LibationLauncher.csproj +++ b/LibationLauncher/LibationLauncher.csproj @@ -13,7 +13,7 @@ win-x64 - 4.0.7.2 + 4.0.8.1 diff --git a/LibationWinForms/UNTESTED/BookLiberation/ProcessorAutomationController.cs b/LibationWinForms/UNTESTED/BookLiberation/ProcessorAutomationController.cs index eabc5623..b6ec10cc 100644 --- a/LibationWinForms/UNTESTED/BookLiberation/ProcessorAutomationController.cs +++ b/LibationWinForms/UNTESTED/BookLiberation/ProcessorAutomationController.cs @@ -10,6 +10,8 @@ public static class ProcessorAutomationController { public static async Task BackupSingleBookAsync(string productId, EventHandler completedAction = null) { + Serilog.Log.Information("Begin " + nameof(BackupSingleBookAsync) + " {@DebugInfo}", new { productId }); + var backupBook = getWiredUpBackupBook(completedAction); var automatedBackupsForm = attachToBackupsForm(backupBook); @@ -20,6 +22,8 @@ public static async Task BackupSingleBookAsync(string productId, EventHandler
  • completedAction = null) { + Serilog.Log.Information("Begin " + nameof(BackupAllBooksAsync)); + var backupBook = getWiredUpBackupBook(completedAction); var automatedBackupsForm = attachToBackupsForm(backupBook); @@ -96,6 +100,8 @@ private static AutomatedBackupsForm attachToBackupsForm(BackupBook backupBook) public static async Task BackupAllPdfsAsync(EventHandler completedAction = null) { + Serilog.Log.Information("Begin " + nameof(BackupAllPdfsAsync)); + var downloadPdf = getWiredUpDownloadPdf(completedAction); var automatedBackupsForm = attachToBackupsForm(downloadPdf);