Improved logging
This commit is contained in:
parent
9e0e06e436
commit
83f538d304
@ -18,6 +18,8 @@ namespace FileLiberator
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class DownloadBook : DownloadableBase
|
public class DownloadBook : DownloadableBase
|
||||||
{
|
{
|
||||||
|
private const string SERVICE_UNAVAILABLE = "Content Delivery Companion Service is not available.";
|
||||||
|
|
||||||
public override bool Validate(LibraryBook libraryBook)
|
public override bool Validate(LibraryBook libraryBook)
|
||||||
=> !AudibleFileStorage.Audio.Exists(libraryBook.Book.AudibleProductId)
|
=> !AudibleFileStorage.Audio.Exists(libraryBook.Book.AudibleProductId)
|
||||||
&& !AudibleFileStorage.AAX.Exists(libraryBook.Book.AudibleProductId);
|
&& !AudibleFileStorage.AAX.Exists(libraryBook.Book.AudibleProductId);
|
||||||
@ -48,18 +50,29 @@ namespace FileLiberator
|
|||||||
System.Threading.Thread.Sleep(100);
|
System.Threading.Thread.Sleep(100);
|
||||||
// if bad file download, a 0-33 byte file will be created
|
// 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 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);
|
libraryBook.Book.Title,
|
||||||
File.Delete(actualFilePath);
|
libraryBook.Book.AudibleProductId,
|
||||||
|
tempAaxFilename,
|
||||||
var unavailable = "Content Delivery Companion Service is not available.";
|
actualFilePath,
|
||||||
if (contents.StartsWithInsensitive(unavailable))
|
length,
|
||||||
throw new Exception(unavailable);
|
contents
|
||||||
throw new Exception("Error downloading file");
|
});
|
||||||
}
|
throw ex;
|
||||||
|
|
||||||
return actualFilePath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void moveBook(LibraryBook libraryBook, string actualFilePath)
|
private void moveBook(LibraryBook libraryBook, string actualFilePath)
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
<!-- <PublishSingleFile>true</PublishSingleFile> -->
|
<!-- <PublishSingleFile>true</PublishSingleFile> -->
|
||||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
|
|
||||||
<Version>3.1.6.2</Version>
|
<Version>3.1.7.5</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -244,10 +244,27 @@ namespace LibationLauncher
|
|||||||
|
|
||||||
private static void logStartupState()
|
private static void logStartupState()
|
||||||
{
|
{
|
||||||
Log.Logger.Information("Begin Libation");
|
var config = Configuration.Instance;
|
||||||
Log.Logger.Information($"Version: {BuildVersion}");
|
|
||||||
Log.Logger.Information($"LibationFiles: {Configuration.Instance.LibationFiles}");
|
Log.Logger.Information("Begin Libation. {@DebugInfo}", new
|
||||||
Log.Logger.Information($"Audible locale: {Configuration.Instance.LocaleCountryCode}");
|
{
|
||||||
|
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;
|
private static Version BuildVersion => System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
|
||||||
|
|||||||
@ -129,18 +129,21 @@ namespace LibationWinForms
|
|||||||
|
|
||||||
// update bottom numbers
|
// update bottom numbers
|
||||||
var pending = noProgress + downloadedOnly;
|
var pending = noProgress + downloadedOnly;
|
||||||
var text
|
var statusStripText
|
||||||
= !results.Any() ? "No books. Begin by importing your library"
|
= !results.Any() ? "No books. Begin by importing your library"
|
||||||
: pending > 0 ? string.Format(backupsCountsLbl_Format, noProgress, downloadedOnly, fullyBackedUp)
|
: pending > 0 ? string.Format(backupsCountsLbl_Format, noProgress, downloadedOnly, fullyBackedUp)
|
||||||
: $"All {"book".PluralizeWithCount(fullyBackedUp)} backed up";
|
: $"All {"book".PluralizeWithCount(fullyBackedUp)} backed up";
|
||||||
statusStrip1.UIThread(() => backupsCountsLbl.Text = text);
|
|
||||||
|
|
||||||
// update menu item
|
// update menu item
|
||||||
var menuItemText
|
var menuItemText
|
||||||
= pending > 0
|
= pending > 0
|
||||||
? $"{pending} remaining"
|
? $"{pending} remaining"
|
||||||
: "All books have been liberated";
|
: "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.Enabled = pending > 0);
|
||||||
menuStrip1.UIThread(() => beginBookBackupsToolStripMenuItem.Text = string.Format(beginBookBackupsToolStripMenuItem_format, menuItemText));
|
menuStrip1.UIThread(() => beginBookBackupsToolStripMenuItem.Text = string.Format(beginBookBackupsToolStripMenuItem_format, menuItemText));
|
||||||
}
|
}
|
||||||
@ -155,18 +158,21 @@ namespace LibationWinForms
|
|||||||
var notDownloaded = boolResults.Count(r => !r);
|
var notDownloaded = boolResults.Count(r => !r);
|
||||||
|
|
||||||
// update bottom numbers
|
// update bottom numbers
|
||||||
var text
|
var statusStripText
|
||||||
= !boolResults.Any() ? ""
|
= !boolResults.Any() ? ""
|
||||||
: notDownloaded > 0 ? string.Format(pdfsCountsLbl_Format, notDownloaded, downloaded)
|
: notDownloaded > 0 ? string.Format(pdfsCountsLbl_Format, notDownloaded, downloaded)
|
||||||
: $"| All {downloaded} PDFs downloaded";
|
: $"| All {downloaded} PDFs downloaded";
|
||||||
statusStrip1.UIThread(() => pdfsCountsLbl.Text = text);
|
|
||||||
|
|
||||||
// update menu item
|
// update menu item
|
||||||
var menuItemText
|
var menuItemText
|
||||||
= notDownloaded > 0
|
= notDownloaded > 0
|
||||||
? $"{notDownloaded} remaining"
|
? $"{notDownloaded} remaining"
|
||||||
: "All PDFs have been downloaded";
|
: "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.Enabled = notDownloaded > 0);
|
||||||
menuStrip1.UIThread(() => beginPdfBackupsToolStripMenuItem.Text = string.Format(beginPdfBackupsToolStripMenuItem_format, menuItemText));
|
menuStrip1.UIThread(() => beginPdfBackupsToolStripMenuItem.Text = string.Format(beginPdfBackupsToolStripMenuItem_format, menuItemText));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
-- begin VERSIONING ---------------------------------------------------------------------------------------------------------------------
|
-- begin VERSIONING ---------------------------------------------------------------------------------------------------------------------
|
||||||
https://github.com/rmcrackan/Libation/releases
|
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.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.5 : Bugfix: some series indexes/sequences could cause library not to import
|
||||||
v3.1.4 : Bugfix: IsAuthorNarrated was returning no books
|
v3.1.4 : Bugfix: IsAuthorNarrated was returning no books
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user