This commit is contained in:
Robert McRackan 2025-03-10 19:11:22 -04:00
commit a37eb383cd
7 changed files with 36 additions and 9 deletions

View File

@ -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<List<ImportItem>> scanAccountsAsync(Func<Account, Task<ApiExtended>> apiExtendedfunc, Account[] accounts, LibraryOptions libraryOptions) private static async Task<List<ImportItem>> scanAccountsAsync(Func<Account, Task<ApiExtended>> apiExtendedfunc, Account[] accounts, LibraryOptions libraryOptions)
{ {
var tasks = new List<Task<List<ImportItem>>>(); var tasks = new List<Task<List<ImportItem>>>();
await using LogArchiver? archiver await using LogArchiver? archiver
= Log.Logger.IsDebugEnabled() = 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; : default;
archiver?.DeleteAllButNewestN(20); archiver?.DeleteAllButNewestN(20);

View File

@ -5,6 +5,7 @@
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="165" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="165"
MinHeight="165" MaxHeight="165" MinHeight="165" MaxHeight="165"
MinWidth="800" MaxWidth="800" MinWidth="800" MaxWidth="800"
Width="800" Height="165"
x:Class="LibationAvalonia.Dialogs.LibationFilesDialog" x:Class="LibationAvalonia.Dialogs.LibationFilesDialog"
xmlns:controls="clr-namespace:LibationAvalonia.Controls" xmlns:controls="clr-namespace:LibationAvalonia.Controls"
WindowStartupLocation="CenterScreen" WindowStartupLocation="CenterScreen"

View File

@ -5,6 +5,7 @@
mc:Ignorable="d" d:DesignWidth="600" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="600" d:DesignHeight="450"
MinWidth="600" MinHeight="450" MinWidth="600" MinHeight="450"
MaxWidth="600" MaxHeight="450" MaxWidth="600" MaxHeight="450"
Width="600" Height="450"
x:Class="LibationAvalonia.Dialogs.MessageBoxAlertAdminDialog" x:Class="LibationAvalonia.Dialogs.MessageBoxAlertAdminDialog"
xmlns:controls="clr-namespace:LibationAvalonia.Controls" xmlns:controls="clr-namespace:LibationAvalonia.Controls"
Title="MessageBoxAlertAdminDialog" Title="MessageBoxAlertAdminDialog"

View File

@ -58,7 +58,7 @@ namespace LibationAvalonia.ViewModels
await Dispatcher.UIThread.InvokeAsync(() => LibraryStats = stats); await Dispatcher.UIThread.InvokeAsync(() => LibraryStats = stats);
if (Configuration.Instance.AutoDownloadEpisodes if (Configuration.Instance.AutoDownloadEpisodes
&& stats.booksNoProgress + stats.pdfsNotDownloaded > 0) && stats.PendingBooks + stats.pdfsNotDownloaded > 0)
await Dispatcher.UIThread.InvokeAsync(BackupAllBooks); await Dispatcher.UIThread.InvokeAsync(BackupAllBooks);
} }
} }

View File

@ -32,8 +32,8 @@ namespace LibationWinForms
var libraryStats = e.Result as LibraryCommands.LibraryStats; var libraryStats = e.Result as LibraryCommands.LibraryStats;
if ((libraryStats.booksNoProgress + libraryStats.pdfsNotDownloaded) > 0) if ((libraryStats.PendingBooks + libraryStats.pdfsNotDownloaded) > 0)
beginBookBackupsToolStripMenuItem_Click(); Invoke(() => beginBookBackupsToolStripMenuItem_Click(null, System.EventArgs.Empty));
}; };
} }

View File

@ -84,7 +84,7 @@ namespace LibationWinForms
public async Task InitLibraryAsync(List<LibraryBook> libraryBooks) public async Task InitLibraryAsync(List<LibraryBook> libraryBooks)
{ {
runBackupCountsAgain = true; runBackupCountsAgain = true;
updateCountsBw.RunWorkerAsync(libraryBooks); setBackupCounts(null, libraryBooks);
await productsDisplay.DisplayAsync(libraryBooks); await productsDisplay.DisplayAsync(libraryBooks);
} }

View File

@ -301,10 +301,6 @@ namespace LibationWinForms.GridView
.BookEntries() .BookEntries()
.ExceptBy(dbBooks.Select(lb => lb.Book.AudibleProductId), ge => ge.AudibleProductId); .ExceptBy(dbBooks.Select(lb => lb.Book.AudibleProductId), ge => ge.AudibleProductId);
removedBooks = bindingList
.AllItems()
.BookEntries().Take(10).ToList();
RemoveBooks(removedBooks); RemoveBooks(removedBooks);
gridEntryDataGridView.FirstDisplayedScrollingRowIndex = topRow; gridEntryDataGridView.FirstDisplayedScrollingRowIndex = topRow;