IsEmpty Filter and other small fixes (#3142)

Co-authored-by: Robbie Davis <robbie@therobbiedavis.com>
This commit is contained in:
Joe Milazzo 2024-09-13 15:15:01 -07:00 committed by GitHub
parent e574caf7eb
commit 07a36176de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
96 changed files with 1361 additions and 1135 deletions

View file

@ -94,7 +94,7 @@ public class DirectoryService : IDirectoryService
private const RegexOptions MatchOptions = RegexOptions.Compiled | RegexOptions.IgnoreCase;
private static readonly Regex ExcludeDirectories = new Regex(
@"@eaDir|\.DS_Store|\.qpkg|__MACOSX|@Recently-Snapshot|@recycle|\.@__thumb|\.caltrash|#recycle",
@"@eaDir|\.DS_Store|\.qpkg|__MACOSX|@Recently-Snapshot|@recycle|\.@__thumb|\.caltrash|#recycle|\.yacreaderlibrary",
MatchOptions,
Tasks.Scanner.Parser.Parser.RegexTimeout);
private static readonly Regex FileCopyAppend = new Regex(@"\(\d+\)",

View file

@ -69,7 +69,8 @@ public class StatisticService : IStatisticService
var totalPagesRead = await _context.AppUserProgresses
.Where(p => p.AppUserId == userId)
.Where(p => libraryIds.Contains(p.LibraryId))
.SumAsync(p => p.PagesRead);
.Select(p => (int?) p.PagesRead)
.SumAsync() ?? 0;
var timeSpentReading = await TimeSpentReadingForUsersAsync(new List<int>() {userId}, libraryIds);

View file

@ -37,7 +37,7 @@ public interface ITaskScheduler
void CovertAllCoversToEncoding();
Task CleanupDbEntries();
Task CheckForUpdate();
Task SyncThemes();
}
public class TaskScheduler : ITaskScheduler
{
@ -165,8 +165,8 @@ public class TaskScheduler : ITaskScheduler
RecurringJob.AddOrUpdate(UpdateYearlyStatsTaskId, () => _statisticService.UpdateServerStatistics(),
Cron.Monthly, RecurringJobOptions);
RecurringJob.AddOrUpdate(SyncThemesTaskId, () => _themeService.SyncThemes(),
Cron.Weekly, RecurringJobOptions);
RecurringJob.AddOrUpdate(SyncThemesTaskId, () => SyncThemes(),
Cron.Daily, RecurringJobOptions);
await ScheduleKavitaPlusTasks();
}
@ -444,6 +444,11 @@ public class TaskScheduler : ITaskScheduler
await _versionUpdaterService.PushUpdate(update);
}
public async Task SyncThemes()
{
await _themeService.SyncThemes();
}
/// <summary>
/// If there is an enqueued or scheduled task for <see cref="ScannerService.ScanLibrary"/> method
/// </summary>

View file

@ -1152,6 +1152,7 @@ public static class Parser
return path.Contains("__MACOSX") || path.StartsWith("@Recently-Snapshot") || path.StartsWith("@recycle")
|| path.StartsWith("._") || Path.GetFileName(path).StartsWith("._") || path.Contains(".qpkg")
|| path.StartsWith("#recycle")
|| path.Contains(".yacreaderlibrary")
|| path.Contains(".caltrash");
}

View file

@ -120,7 +120,11 @@ public class ThemeService : IThemeService
public async Task<List<DownloadableSiteThemeDto>> GetDownloadableThemes()
{
const string cacheKey = "browse";
var existingThemes = (await _unitOfWork.SiteThemeRepository.GetThemeDtos()).ToDictionary(k => k.Name);
// Avoid a duplicate Dark issue some users faced during migration
var existingThemes = (await _unitOfWork.SiteThemeRepository.GetThemeDtos())
.GroupBy(k => k.Name)
.ToDictionary(g => g.Key, g => g.First());
if (_cache.TryGetValue(cacheKey, out List<DownloadableSiteThemeDto>? themes) && themes != null)
{
foreach (var t in themes)
@ -204,6 +208,13 @@ public class ThemeService : IThemeService
/// <returns></returns>
private async Task<IDictionary<string, ThemeMetadata>> GetReadme()
{
// Try and delete a Readme file if it already exists
var existingReadmeFile = _directoryService.FileSystem.Path.Join(_directoryService.TempDirectory, "README.md");
if (_directoryService.FileSystem.File.Exists(existingReadmeFile))
{
_directoryService.DeleteFiles([existingReadmeFile]);
}
var tempDownloadFile = await GithubReadme.DownloadFileAsync(_directoryService.TempDirectory);
// Read file into Markdown