Skip to content

Commit

Permalink
Bug fix: downloading PDFs without also Liberating books -- post-downl…
Browse files Browse the repository at this point in the history
…oad verification step was failing
  • Loading branch information
Robert McRackan committed Sep 22, 2020
1 parent 2b3f67f commit e971d34
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
18 changes: 12 additions & 6 deletions FileLiberator/UNTESTED/DownloadPdf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion LibationLauncher/LibationLauncher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<!-- <PublishSingleFile>true</PublishSingleFile> -->
<RuntimeIdentifier>win-x64</RuntimeIdentifier>

<Version>4.0.7.2</Version>
<Version>4.0.8.1</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public static class ProcessorAutomationController
{
public static async Task BackupSingleBookAsync(string productId, EventHandler<LibraryBook> completedAction = null)
{
Serilog.Log.Information("Begin " + nameof(BackupSingleBookAsync) + " {@DebugInfo}", new { productId });

var backupBook = getWiredUpBackupBook(completedAction);

var automatedBackupsForm = attachToBackupsForm(backupBook);
Expand All @@ -20,6 +22,8 @@ public static async Task BackupSingleBookAsync(string productId, EventHandler<Li

public static async Task BackupAllBooksAsync(EventHandler<LibraryBook> completedAction = null)
{
Serilog.Log.Information("Begin " + nameof(BackupAllBooksAsync));

var backupBook = getWiredUpBackupBook(completedAction);

var automatedBackupsForm = attachToBackupsForm(backupBook);
Expand Down Expand Up @@ -96,6 +100,8 @@ private static AutomatedBackupsForm attachToBackupsForm(BackupBook backupBook)

public static async Task BackupAllPdfsAsync(EventHandler<LibraryBook> completedAction = null)
{
Serilog.Log.Information("Begin " + nameof(BackupAllPdfsAsync));

var downloadPdf = getWiredUpDownloadPdf(completedAction);

var automatedBackupsForm = attachToBackupsForm(downloadPdf);
Expand Down

0 comments on commit e971d34

Please sign in to comment.