diff --git a/DataLayer/EfClasses/Book.cs b/DataLayer/EfClasses/Book.cs
index c9f87c5b..da366bfa 100644
--- a/DataLayer/EfClasses/Book.cs
+++ b/DataLayer/EfClasses/Book.cs
@@ -57,7 +57,6 @@ namespace DataLayer
get
{
var status = UserDefinedItem?.BookStatus;
- // true since Error == libhack
return status.HasValue && status.Value != LiberatedStatus.NotLiberated;
}
}
diff --git a/FileManager/AudibleFileStorage.cs b/FileManager/AudibleFileStorage.cs
index b88d7ca7..3456597b 100644
--- a/FileManager/AudibleFileStorage.cs
+++ b/FileManager/AudibleFileStorage.cs
@@ -96,9 +96,7 @@ namespace FileManager
public class AudioFileStorage : AudibleFileStorage
{
- public const string SKIP_FILE_EXT = "libhack";
-
- protected override string[] Extensions { get; } = new[] { "m4b", "mp3", "aac", "mp4", "m4a", "ogg", "flac", SKIP_FILE_EXT };
+ protected override string[] Extensions { get; } = new[] { "m4b", "mp3", "aac", "mp4", "m4a", "ogg", "flac" };
// we always want to use the latest config value, therefore
// - DO use 'get' arrow "=>"
@@ -109,17 +107,6 @@ namespace FileManager
public void Refresh() => BookDirectoryFiles.RefreshFiles();
- public string CreateSkipFile(string title, string asin, string contents = null)
- {
- var destinationDir = GetDestDir(title, asin);
- Directory.CreateDirectory(destinationDir);
-
- var path = FileUtility.GetValidFilename(destinationDir, title, SKIP_FILE_EXT, asin);
- File.WriteAllText(path, contents ?? string.Empty);
-
- return path;
- }
-
public string GetDestDir(string title, string asin)
{
// to prevent the paths from getting too long, we don't need after the 1st ":" for the folder
diff --git a/LibationLauncher/LibationLauncher.csproj b/LibationLauncher/LibationLauncher.csproj
index bc29d580..c0bfa4a4 100644
--- a/LibationLauncher/LibationLauncher.csproj
+++ b/LibationLauncher/LibationLauncher.csproj
@@ -13,7 +13,7 @@
win-x64
- 5.5.1.20
+ 5.5.1.27
diff --git a/LibationLauncher/Program.cs b/LibationLauncher/Program.cs
index 93aeaed8..267752a9 100644
--- a/LibationLauncher/Program.cs
+++ b/LibationLauncher/Program.cs
@@ -5,13 +5,14 @@ using System.Linq;
using System.Windows.Forms;
using AudibleApi.Authorization;
using DataLayer;
-using Microsoft.EntityFrameworkCore;
+using Dinah.Core;
using Dinah.Core.IO;
using Dinah.Core.Logging;
using FileManager;
using InternalUtilities;
using LibationWinForms;
using LibationWinForms.Dialogs;
+using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json.Linq;
using Serilog;
@@ -244,6 +245,11 @@ namespace LibationLauncher
if (!File.Exists(filePaths))
return;
+ // files to be deleted at the end
+ var libhackFilesToDelete = new List();
+ // .libhack files => errors
+ var libhackFiles = Directory.EnumerateDirectories(config.Books, "*.libhack", SearchOption.AllDirectories);
+
using var context = ApplicationServices.DbContexts.GetContext();
context.Books.Load();
@@ -274,11 +280,24 @@ namespace LibationLauncher
book.UserDefinedItem.PdfStatus = LiberatedStatus.Liberated;
if (fileType == FileType.Audio)
- book.UserDefinedItem.BookStatus = LiberatedStatus.Liberated;
+ {
+ var lhack = libhackFiles.FirstOrDefault(f => f.ContainsInsensitive(asin));
+ if (lhack is null)
+ book.UserDefinedItem.BookStatus = LiberatedStatus.Liberated;
+ else
+ {
+ book.UserDefinedItem.BookStatus = LiberatedStatus.Error;
+ libhackFilesToDelete.Add(lhack);
+ }
+ }
}
context.SaveChanges();
+ // only do this after save changes
+ foreach (var libhackFile in libhackFilesToDelete)
+ File.Delete(libhackFile);
+
File.Delete(filePaths);
}
catch (Exception ex)
diff --git a/LibationWinForms/BookLiberation/ProcessorAutomationController.cs b/LibationWinForms/BookLiberation/ProcessorAutomationController.cs
index 9eff3348..034be1af 100644
--- a/LibationWinForms/BookLiberation/ProcessorAutomationController.cs
+++ b/LibationWinForms/BookLiberation/ProcessorAutomationController.cs
@@ -176,7 +176,7 @@ namespace LibationWinForms.BookLiberation
protected abstract string SkipDialogText { get; }
protected abstract MessageBoxButtons SkipDialogButtons { get; }
protected abstract MessageBoxDefaultButton SkipDialogDefaultButton { get; }
- protected abstract DialogResult CreateSkipFileResult { get; }
+ protected abstract DialogResult SkipResult { get; }
public async Task RunBackupAsync()
{
@@ -244,15 +244,10 @@ $@" Title: {libraryBook.Book.Title}
if (dialogResult == DialogResult.Abort)
return false;
- if (dialogResult == CreateSkipFileResult)
+ if (dialogResult == SkipResult)
{
ApplicationServices.LibraryCommands.UpdateBook(libraryBook, LiberatedStatus.Error);
- var path = FileManager.AudibleFileStorage.Audio.CreateSkipFile(libraryBook.Book.Title, libraryBook.Book.AudibleProductId, logMessage);
- LogMe.Info($@"
-Created new 'skip' file
- [{libraryBook.Book.AudibleProductId}] {libraryBook.Book.Title}
- {path}
-".Trim());
+ LogMe.Info($"Error. Skip: [{libraryBook.Book.AudibleProductId}] {libraryBook.Book.Title}");
}
return true;
@@ -273,7 +268,7 @@ An error occurred while trying to process this book. Skip this book permanently?
".Trim();
protected override MessageBoxButtons SkipDialogButtons => MessageBoxButtons.YesNo;
protected override MessageBoxDefaultButton SkipDialogDefaultButton => MessageBoxDefaultButton.Button2;
- protected override DialogResult CreateSkipFileResult => DialogResult.Yes;
+ protected override DialogResult SkipResult => DialogResult.Yes;
public BackupSingle(LogMe logMe, IProcessable processable, LibraryBook libraryBook)
: base(logMe, processable)
@@ -302,7 +297,7 @@ An error occurred while trying to process this book.
".Trim();
protected override MessageBoxButtons SkipDialogButtons => MessageBoxButtons.AbortRetryIgnore;
protected override MessageBoxDefaultButton SkipDialogDefaultButton => MessageBoxDefaultButton.Button1;
- protected override DialogResult CreateSkipFileResult => DialogResult.Ignore;
+ protected override DialogResult SkipResult => DialogResult.Ignore;
public BackupLoop(LogMe logMe, IProcessable processable, AutomatedBackupsForm automatedBackupsForm)
: base(logMe, processable, automatedBackupsForm) { }