Release Polish (#1586)

* Fixed a scaling issue in the epub reader, where images could scale when they shouldn't.

* Removed some caching on library/ api and added more output for a foreign key constraint

* Hooked in Restricted Profile stat collection

* Added a new boolean on age restrictions to explicitly allow unknowns or not. Since unknown is the default state of metadata, if users are allowed access to Unknown, age restricted content could leak.

* Fixed a bug where sometimes series cover generation could fail under conditions where only specials existed.

* Fixed foreign constraint issue when cleaning up series not seen at end of scan loop

* Removed an additional epub parse when scanning and handled merging differently

* Code smell
This commit is contained in:
Joe Milazzo 2022-10-17 15:33:18 -07:00 committed by GitHub
parent 78762a5626
commit 9149c4cbca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 2504 additions and 145 deletions

View file

@ -130,17 +130,8 @@ public class MetadataService : IMetadataService
return Task.CompletedTask;
series.Volumes ??= new List<Volume>();
var firstCover = series.Volumes.GetCoverImage(series.Format);
string coverImage = null;
series.CoverImage = series.GetCoverImage();
var chapters = firstCover.Chapters.OrderBy(c => double.Parse(c.Number), ChapterSortComparerZeroFirst.Default).ToList();
if (chapters.Count > 1 && chapters.Any(c => c.IsSpecial))
{
coverImage = chapters.First(c => !c.IsSpecial).CoverImage ?? chapters.First().CoverImage;
firstCover = null;
}
series.CoverImage = firstCover?.CoverImage ?? coverImage;
_updateEvents.Add(MessageFactory.CoverUpdateEvent(series.Id, MessageFactoryEntityTypes.Series));
return Task.CompletedTask;
}

View file

@ -72,8 +72,7 @@ public class ReadingItemService : IReadingItemService
// This catches when original library type is Manga/Comic and when parsing with non
if (Tasks.Scanner.Parser.Parser.IsEpub(path) && Tasks.Scanner.Parser.Parser.ParseVolume(info.Series) != Tasks.Scanner.Parser.Parser.DefaultVolume) // Shouldn't this be info.Volume != DefaultVolume?
{
info = _defaultParser.Parse(path, rootPath, LibraryType.Book);
var info2 = Parse(path, rootPath, type);
var info2 = _defaultParser.Parse(path, rootPath, LibraryType.Book);
info.Merge(info2);
}

View file

@ -239,7 +239,7 @@ public class TaskScheduler : ITaskScheduler
_logger.LogInformation("Enqueuing library scan for: {LibraryId}", libraryId);
BackgroundJob.Enqueue(() => _scannerService.ScanLibrary(libraryId, force));
// When we do a scan, force cache to re-unpack in case page numbers change
BackgroundJob.Enqueue(() => _cleanupService.CleanupCacheDirectory());
BackgroundJob.Enqueue(() => _cleanupService.CleanupCacheAndTempDirectories());
}
public void CleanupChapters(int[] chapterIds)

View file

@ -20,7 +20,7 @@ public interface ICleanupService
{
Task Cleanup();
Task CleanupDbEntries();
void CleanupCacheDirectory();
void CleanupCacheAndTempDirectories();
Task DeleteSeriesCoverImages();
Task DeleteChapterCoverImages();
Task DeleteTagCoverImages();
@ -65,7 +65,7 @@ public class CleanupService : ICleanupService
_logger.LogInformation("Cleaning temp directory");
_directoryService.ClearDirectory(_directoryService.TempDirectory);
await SendProgress(0.1F, "Cleaning temp directory");
CleanupCacheDirectory();
CleanupCacheAndTempDirectories();
await SendProgress(0.25F, "Cleaning old database backups");
_logger.LogInformation("Cleaning old database backups");
await CleanupBackups();
@ -143,9 +143,9 @@ public class CleanupService : ICleanupService
/// <summary>
/// Removes all files and directories in the cache and temp directory
/// </summary>
public void CleanupCacheDirectory()
public void CleanupCacheAndTempDirectories()
{
_logger.LogInformation("Performing cleanup of Cache directory");
_logger.LogInformation("Performing cleanup of Cache & Temp directories");
_directoryService.ExistOrCreate(_directoryService.CacheDirectory);
_directoryService.ExistOrCreate(_directoryService.TempDirectory);
@ -159,7 +159,7 @@ public class CleanupService : ICleanupService
_logger.LogError(ex, "There was an issue deleting one or more folders/files during cleanup");
}
_logger.LogInformation("Cache directory purged");
_logger.LogInformation("Cache and temp directory purged");
}
/// <summary>

View file

@ -29,12 +29,6 @@ public class ParsedSeries
public MangaFormat Format { get; init; }
}
public enum Modified
{
Modified = 1,
NotModified = 2
}
public class SeriesModified
{
public string FolderPath { get; set; }

View file

@ -506,11 +506,6 @@ public class ScannerService : IScannerService
library.LastScanned = time;
// Could I delete anything in a Library's Series where the LastScan date is before scanStart?
// NOTE: This implementation is expensive
_logger.LogDebug("Removing Series that were not found during the scan");
var removedSeries = await _unitOfWork.SeriesRepository.RemoveSeriesNotInList(seenSeries, library.Id);
_logger.LogDebug("Removing Series that were not found during the scan - complete");
_unitOfWork.LibraryRepository.Update(library);
if (await _unitOfWork.CommitAsync())
@ -528,10 +523,27 @@ public class ScannerService : IScannerService
totalFiles, seenSeries.Count, sw.ElapsedMilliseconds, library.Name);
}
foreach (var s in removedSeries)
try
{
await _eventHub.SendMessageAsync(MessageFactory.SeriesRemoved,
MessageFactory.SeriesRemovedEvent(s.Id, s.Name, s.LibraryId), false);
// Could I delete anything in a Library's Series where the LastScan date is before scanStart?
// NOTE: This implementation is expensive
_logger.LogDebug("[ScannerService] Removing Series that were not found during the scan");
var removedSeries = await _unitOfWork.SeriesRepository.RemoveSeriesNotInList(seenSeries, library.Id);
_logger.LogDebug("[ScannerService] Found {Count} series that needs to be removed: {SeriesList}",
removedSeries.Count, removedSeries.Select(s => s.Name));
_logger.LogDebug("[ScannerService] Removing Series that were not found during the scan - complete");
await _unitOfWork.CommitAsync();
foreach (var s in removedSeries)
{
await _eventHub.SendMessageAsync(MessageFactory.SeriesRemoved,
MessageFactory.SeriesRemovedEvent(s.Id, s.Name, s.LibraryId), false);
}
}
catch (Exception ex)
{
_logger.LogCritical(ex, "[ScannerService] There was an issue deleting series for cleanup. Please check logs and rescan");
}
}
else
@ -584,4 +596,5 @@ public class ScannerService : IScannerService
{
return existingSeries.Where(es => !ParserInfoHelpers.SeriesHasMatchingParserInfoFormat(es, parsedSeries));
}
}

View file

@ -134,6 +134,7 @@ public class StatsService : IStatsService
MangaReaderPageSplittingModes = await AllMangaReaderPageSplitting(),
MangaReaderLayoutModes = await AllMangaReaderLayoutModes(),
FileFormats = AllFormats(),
UsingRestrictedProfiles = await GetUsingRestrictedProfiles(),
};
var usersWithPref = (await _unitOfWork.UserRepository.GetAllUsersAsync(AppUserIncludes.UserPreferences)).ToList();
@ -261,4 +262,9 @@ public class StatsService : IStatsService
return results;
}
private Task<bool> GetUsingRestrictedProfiles()
{
return _context.Users.AnyAsync(u => u.AgeRestriction > AgeRating.NotApplicable);
}
}