diff --git a/FileLiberator/UNTESTED/DownloadBook.cs b/FileLiberator/UNTESTED/DownloadBook.cs
index db13bd83..4737ea91 100644
--- a/FileLiberator/UNTESTED/DownloadBook.cs
+++ b/FileLiberator/UNTESTED/DownloadBook.cs
@@ -18,6 +18,8 @@ namespace FileLiberator
///
public class DownloadBook : DownloadableBase
{
+ private const string SERVICE_UNAVAILABLE = "Content Delivery Companion Service is not available.";
+
public override bool Validate(LibraryBook libraryBook)
=> !AudibleFileStorage.Audio.Exists(libraryBook.Book.AudibleProductId)
&& !AudibleFileStorage.AAX.Exists(libraryBook.Book.AudibleProductId);
@@ -48,18 +50,29 @@ namespace FileLiberator
System.Threading.Thread.Sleep(100);
// if bad file download, a 0-33 byte file will be created
// if service unavailable, a 52 byte string will be saved as file
- if (new FileInfo(actualFilePath).Length < 100)
+ var length = new FileInfo(actualFilePath).Length;
+
+ if (length > 100)
+ return actualFilePath;
+
+ var contents = File.ReadAllText(actualFilePath);
+ File.Delete(actualFilePath);
+
+ var exMsg = contents.StartsWithInsensitive(SERVICE_UNAVAILABLE)
+ ? SERVICE_UNAVAILABLE
+ : "Error downloading file";
+
+ var ex = new Exception(exMsg);
+ Serilog.Log.Error(ex, "Download error {@DebugInfo}", new
{
- var contents = File.ReadAllText(actualFilePath);
- File.Delete(actualFilePath);
-
- var unavailable = "Content Delivery Companion Service is not available.";
- if (contents.StartsWithInsensitive(unavailable))
- throw new Exception(unavailable);
- throw new Exception("Error downloading file");
- }
-
- return actualFilePath;
+ libraryBook.Book.Title,
+ libraryBook.Book.AudibleProductId,
+ tempAaxFilename,
+ actualFilePath,
+ length,
+ contents
+ });
+ throw ex;
}
private void moveBook(LibraryBook libraryBook, string actualFilePath)
diff --git a/LibationLauncher/LibationLauncher.csproj b/LibationLauncher/LibationLauncher.csproj
index 85c1bb07..c2f149cd 100644
--- a/LibationLauncher/LibationLauncher.csproj
+++ b/LibationLauncher/LibationLauncher.csproj
@@ -13,7 +13,7 @@
win-x64
- 3.1.6.2
+ 3.1.7.5
diff --git a/LibationLauncher/UNTESTED/Program.cs b/LibationLauncher/UNTESTED/Program.cs
index 9a42a72e..0cbd90ad 100644
--- a/LibationLauncher/UNTESTED/Program.cs
+++ b/LibationLauncher/UNTESTED/Program.cs
@@ -244,10 +244,27 @@ namespace LibationLauncher
private static void logStartupState()
{
- Log.Logger.Information("Begin Libation");
- Log.Logger.Information($"Version: {BuildVersion}");
- Log.Logger.Information($"LibationFiles: {Configuration.Instance.LibationFiles}");
- Log.Logger.Information($"Audible locale: {Configuration.Instance.LocaleCountryCode}");
+ var config = Configuration.Instance;
+
+ Log.Logger.Information("Begin Libation. {@DebugInfo}", new
+ {
+ Version = BuildVersion.ToString(),
+
+ AudibleLocale = config.LocaleCountryCode,
+ config.LibationFiles,
+ AudibleFileStorage.BooksDirectory,
+
+ config.DownloadsInProgressEnum,
+ DownloadsInProgressDir = AudibleFileStorage.DownloadsInProgress,
+ DownloadsInProgressFiles = Directory.EnumerateFiles(AudibleFileStorage.DownloadsInProgress).Count(),
+
+ AudibleFileStorage.DownloadsFinal,
+ DownloadsFinalFiles = Directory.EnumerateFiles(AudibleFileStorage.DownloadsFinal).Count(),
+
+ config.DecryptInProgressEnum,
+ DecryptInProgressDir = AudibleFileStorage.DecryptInProgress,
+ DecryptInProgressFiles = Directory.EnumerateFiles(AudibleFileStorage.DecryptInProgress).Count(),
+ });
}
private static Version BuildVersion => System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
diff --git a/LibationWinForms/UNTESTED/Form1.cs b/LibationWinForms/UNTESTED/Form1.cs
index a41fc307..e98dd58f 100644
--- a/LibationWinForms/UNTESTED/Form1.cs
+++ b/LibationWinForms/UNTESTED/Form1.cs
@@ -129,18 +129,21 @@ namespace LibationWinForms
// update bottom numbers
var pending = noProgress + downloadedOnly;
- var text
+ var statusStripText
= !results.Any() ? "No books. Begin by importing your library"
: pending > 0 ? string.Format(backupsCountsLbl_Format, noProgress, downloadedOnly, fullyBackedUp)
: $"All {"book".PluralizeWithCount(fullyBackedUp)} backed up";
- statusStrip1.UIThread(() => backupsCountsLbl.Text = text);
// update menu item
var menuItemText
= pending > 0
? $"{pending} remaining"
: "All books have been liberated";
- Serilog.Log.Logger.Information(menuItemText);
+
+ Serilog.Log.Logger.Information("Book counts. {@DebugInfo}", new { fullyBackedUp, downloadedOnly, noProgress, pending, statusStripText, menuItemText });
+
+ // update UI
+ statusStrip1.UIThread(() => backupsCountsLbl.Text = statusStripText);
menuStrip1.UIThread(() => beginBookBackupsToolStripMenuItem.Enabled = pending > 0);
menuStrip1.UIThread(() => beginBookBackupsToolStripMenuItem.Text = string.Format(beginBookBackupsToolStripMenuItem_format, menuItemText));
}
@@ -155,18 +158,21 @@ namespace LibationWinForms
var notDownloaded = boolResults.Count(r => !r);
// update bottom numbers
- var text
+ var statusStripText
= !boolResults.Any() ? ""
: notDownloaded > 0 ? string.Format(pdfsCountsLbl_Format, notDownloaded, downloaded)
: $"| All {downloaded} PDFs downloaded";
- statusStrip1.UIThread(() => pdfsCountsLbl.Text = text);
// update menu item
var menuItemText
= notDownloaded > 0
? $"{notDownloaded} remaining"
: "All PDFs have been downloaded";
- Serilog.Log.Logger.Information(menuItemText);
+
+ Serilog.Log.Logger.Information("PDF counts. {@DebugInfo}", new { downloaded, notDownloaded, statusStripText, menuItemText });
+
+ // update UI
+ statusStrip1.UIThread(() => pdfsCountsLbl.Text = statusStripText);
menuStrip1.UIThread(() => beginPdfBackupsToolStripMenuItem.Enabled = notDownloaded > 0);
menuStrip1.UIThread(() => beginPdfBackupsToolStripMenuItem.Text = string.Format(beginPdfBackupsToolStripMenuItem_format, menuItemText));
}
diff --git a/REFERENCE.txt b/REFERENCE.txt
index 86a4442e..bd3a5cd8 100644
--- a/REFERENCE.txt
+++ b/REFERENCE.txt
@@ -1,6 +1,7 @@
-- begin VERSIONING ---------------------------------------------------------------------------------------------------------------------
https://github.com/rmcrackan/Libation/releases
+v3.1.7 : Improved logging
v3.1.6 : Bugfix: some series indexes/sequences formats cause library not to import
v3.1.5 : Bugfix: some series indexes/sequences could cause library not to import
v3.1.4 : Bugfix: IsAuthorNarrated was returning no books