From 65e12d9a8f805db6e7b8100a2ee7984e55f4e6c3 Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Mon, 10 Mar 2025 09:07:35 -0600 Subject: [PATCH 1/4] Add default window dimensions --- Source/LibationAvalonia/Dialogs/LibationFilesDialog.axaml | 1 + Source/LibationAvalonia/Dialogs/MessageBoxAlertAdminDialog.axaml | 1 + 2 files changed, 2 insertions(+) diff --git a/Source/LibationAvalonia/Dialogs/LibationFilesDialog.axaml b/Source/LibationAvalonia/Dialogs/LibationFilesDialog.axaml index e611e50d..ce8c93fb 100644 --- a/Source/LibationAvalonia/Dialogs/LibationFilesDialog.axaml +++ b/Source/LibationAvalonia/Dialogs/LibationFilesDialog.axaml @@ -5,6 +5,7 @@ mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="165" MinHeight="165" MaxHeight="165" MinWidth="800" MaxWidth="800" + Width="800" Height="165" x:Class="LibationAvalonia.Dialogs.LibationFilesDialog" xmlns:controls="clr-namespace:LibationAvalonia.Controls" WindowStartupLocation="CenterScreen" diff --git a/Source/LibationAvalonia/Dialogs/MessageBoxAlertAdminDialog.axaml b/Source/LibationAvalonia/Dialogs/MessageBoxAlertAdminDialog.axaml index 85ad861d..6a91166d 100644 --- a/Source/LibationAvalonia/Dialogs/MessageBoxAlertAdminDialog.axaml +++ b/Source/LibationAvalonia/Dialogs/MessageBoxAlertAdminDialog.axaml @@ -5,6 +5,7 @@ mc:Ignorable="d" d:DesignWidth="600" d:DesignHeight="450" MinWidth="600" MinHeight="450" MaxWidth="600" MaxHeight="450" + Width="600" Height="450" x:Class="LibationAvalonia.Dialogs.MessageBoxAlertAdminDialog" xmlns:controls="clr-namespace:LibationAvalonia.Controls" Title="MessageBoxAlertAdminDialog" From ee05ca4eb218596f5548f48f17b8ff42546f8554 Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Mon, 10 Mar 2025 09:49:22 -0600 Subject: [PATCH 2/4] Handle corrupted LibraryScans.zip file (#1185) --- Source/ApplicationServices/LibraryCommands.cs | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/Source/ApplicationServices/LibraryCommands.cs b/Source/ApplicationServices/LibraryCommands.cs index d8a9d2d2..9278b084 100644 --- a/Source/ApplicationServices/LibraryCommands.cs +++ b/Source/ApplicationServices/LibraryCommands.cs @@ -233,13 +233,42 @@ namespace ApplicationServices } } + private static LogArchiver? openLogArchive(string? archivePath) + { + if (string.IsNullOrWhiteSpace(archivePath)) + return null; + + try + { + return new LogArchiver(archivePath); + } + catch (System.IO.InvalidDataException) + { + try + { + Log.Logger.Warning($"Deleting corrupted {nameof(LogArchiver)} at {archivePath}"); + FileUtility.SaferDelete(archivePath); + return new LogArchiver(archivePath); + } + catch (Exception ex) + { + Log.Logger.Error(ex, $"Failed to open {nameof(LogArchiver)} at {archivePath}"); + } + } + catch (Exception ex) + { + Log.Logger.Error(ex, $"Failed to open {nameof(LogArchiver)} at {archivePath}"); + } + return null; + } + private static async Task> scanAccountsAsync(Func> apiExtendedfunc, Account[] accounts, LibraryOptions libraryOptions) { var tasks = new List>>(); await using LogArchiver? archiver = Log.Logger.IsDebugEnabled() - ? new LogArchiver(System.IO.Path.Combine(Configuration.Instance.LibationFiles, "LibraryScans.zip")) + ? openLogArchive(System.IO.Path.Combine(Configuration.Instance.LibationFiles, "LibraryScans.zip")) : default; archiver?.DeleteAllButNewestN(20); From 4e067f5b5b2c58bffbbbd64b3d05a51fd1215a58 Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Mon, 10 Mar 2025 10:46:36 -0600 Subject: [PATCH 3/4] Remove inadvertently committed debugging code --- Source/LibationWinForms/GridView/ProductsGrid.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Source/LibationWinForms/GridView/ProductsGrid.cs b/Source/LibationWinForms/GridView/ProductsGrid.cs index 9a7f31c7..c4026d6f 100644 --- a/Source/LibationWinForms/GridView/ProductsGrid.cs +++ b/Source/LibationWinForms/GridView/ProductsGrid.cs @@ -301,10 +301,6 @@ namespace LibationWinForms.GridView .BookEntries() .ExceptBy(dbBooks.Select(lb => lb.Book.AudibleProductId), ge => ge.AudibleProductId); - removedBooks = bindingList - .AllItems() - .BookEntries().Take(10).ToList(); - RemoveBooks(removedBooks); gridEntryDataGridView.FirstDisplayedScrollingRowIndex = topRow; From 653381b1dfe6ac1be5a76cd316c34fea4a4de3cd Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Mon, 10 Mar 2025 10:48:57 -0600 Subject: [PATCH 4/4] Fix Auto download not working sometimes (#1183) --- Source/LibationAvalonia/ViewModels/MainVM.BackupCounts.cs | 2 +- Source/LibationWinForms/Form1._NonUI.cs | 4 ++-- Source/LibationWinForms/Form1.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/LibationAvalonia/ViewModels/MainVM.BackupCounts.cs b/Source/LibationAvalonia/ViewModels/MainVM.BackupCounts.cs index 8060552a..deebd59c 100644 --- a/Source/LibationAvalonia/ViewModels/MainVM.BackupCounts.cs +++ b/Source/LibationAvalonia/ViewModels/MainVM.BackupCounts.cs @@ -58,7 +58,7 @@ namespace LibationAvalonia.ViewModels await Dispatcher.UIThread.InvokeAsync(() => LibraryStats = stats); if (Configuration.Instance.AutoDownloadEpisodes - && stats.booksNoProgress + stats.pdfsNotDownloaded > 0) + && stats.PendingBooks + stats.pdfsNotDownloaded > 0) await Dispatcher.UIThread.InvokeAsync(BackupAllBooks); } } diff --git a/Source/LibationWinForms/Form1._NonUI.cs b/Source/LibationWinForms/Form1._NonUI.cs index 3c91142d..7d362b60 100644 --- a/Source/LibationWinForms/Form1._NonUI.cs +++ b/Source/LibationWinForms/Form1._NonUI.cs @@ -32,8 +32,8 @@ namespace LibationWinForms var libraryStats = e.Result as LibraryCommands.LibraryStats; - if ((libraryStats.booksNoProgress + libraryStats.pdfsNotDownloaded) > 0) - beginBookBackupsToolStripMenuItem_Click(); + if ((libraryStats.PendingBooks + libraryStats.pdfsNotDownloaded) > 0) + Invoke(() => beginBookBackupsToolStripMenuItem_Click(null, System.EventArgs.Empty)); }; } diff --git a/Source/LibationWinForms/Form1.cs b/Source/LibationWinForms/Form1.cs index 33b06b0e..876e2ca8 100644 --- a/Source/LibationWinForms/Form1.cs +++ b/Source/LibationWinForms/Form1.cs @@ -84,7 +84,7 @@ namespace LibationWinForms public async Task InitLibraryAsync(List libraryBooks) { runBackupCountsAgain = true; - updateCountsBw.RunWorkerAsync(libraryBooks); + setBackupCounts(null, libraryBooks); await productsDisplay.DisplayAsync(libraryBooks); }