mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-07-09 03:04:19 -04:00
Implemented partial chapter support. Fixed some edge case where if library scan was skipped due to no modififcation on disk, whole library would be removed. Removed above code for testing.
This commit is contained in:
parent
b30560fdda
commit
57f74d3de3
@ -102,10 +102,6 @@ namespace API.Controllers
|
||||
.Include(u => u.UserPreferences)
|
||||
.SingleOrDefaultAsync(x => x.NormalizedUserName == loginDto.Username.ToUpper());
|
||||
|
||||
var debugUsers = await _userManager.Users.Select(x => x.NormalizedUserName).ToListAsync();
|
||||
|
||||
_logger.LogInformation($"All Users: {string.Join(",", debugUsers)}");
|
||||
|
||||
if (user == null) return Unauthorized("Invalid username");
|
||||
|
||||
var result = await _signInManager
|
||||
|
@ -111,28 +111,28 @@ namespace API.Parser
|
||||
private static readonly Regex[] MangaChapterRegex = new[]
|
||||
{
|
||||
new Regex(
|
||||
@"(c|ch)(\.? ?)(?<Chapter>\d+-?\d*)",
|
||||
@"(c|ch)(\.? ?)(?<Chapter>\d+(?:.\d+|-\d+)?)",
|
||||
RegexOptions.IgnoreCase | RegexOptions.Compiled),
|
||||
// [Suihei Kiki]_Kasumi_Otoko_no_Ko_[Taruby]_v1.1.zip
|
||||
new Regex(
|
||||
|
||||
@"v\d+\.(?<Chapter>\d+-?\d*)",
|
||||
@"v\d+\.(?<Chapter>\d+(?:.\d+|-\d+)?)",
|
||||
RegexOptions.IgnoreCase | RegexOptions.Compiled),
|
||||
// Hinowa ga CRUSH! 018 (2019) (Digital) (LuCaZ).cbz
|
||||
// Hinowa ga CRUSH! 018 (2019) (Digital) (LuCaZ).cbz,Hinowa ga CRUSH! 018.5 (2019) (Digital) (LuCaZ).cbz
|
||||
new Regex(
|
||||
@"(?<Series>.*) (?<Chapter>\d+) (?:\(\d{4}\))",
|
||||
@"(?<Series>.*) (?<Chapter>\d+(?:.\d+|-\d+)?)(?: \(\d{4}\))?",
|
||||
RegexOptions.IgnoreCase | RegexOptions.Compiled),
|
||||
// Tower Of God S01 014 (CBT) (digital).cbz
|
||||
new Regex(
|
||||
@"(?<Series>.*) S(?<Volume>\d+) (?<Chapter>\d+)",
|
||||
@"(?<Series>.*) S(?<Volume>\d+) (?<Chapter>\d+(?:.\d+|-\d+)?)",
|
||||
RegexOptions.IgnoreCase | RegexOptions.Compiled),
|
||||
// Beelzebub_01_[Noodles].zip
|
||||
new Regex(
|
||||
@"^((?!v|vo|vol|Volume).)*( |_)(?<Chapter>\.?\d+)( |_|\[|\()",
|
||||
@"^((?!v|vo|vol|Volume).)*( |_)(?<Chapter>\.?\d+(?:.\d+|-\d+)?)( |_|\[|\()",
|
||||
RegexOptions.IgnoreCase | RegexOptions.Compiled),
|
||||
// Yumekui-Merry_DKThias_Chapter21.zip
|
||||
new Regex(
|
||||
@"Chapter(?<Chapter>\d+(-\d+)?)",
|
||||
@"Chapter(?<Chapter>\d+(-\d+)?)", //(?:.\d+|-\d+)?
|
||||
RegexOptions.IgnoreCase | RegexOptions.Compiled),
|
||||
|
||||
};
|
||||
|
@ -57,13 +57,16 @@ namespace API.Services
|
||||
_logger.LogInformation($"Beginning scan on {library.Name}. Forcing metadata update: {forceUpdate}");
|
||||
|
||||
var totalFiles = 0;
|
||||
var skippedFolders = 0;
|
||||
foreach (var folderPath in library.Folders)
|
||||
{
|
||||
if (!forceUpdate && Directory.GetLastWriteTime(folderPath.Path) <= folderPath.LastScanned)
|
||||
{
|
||||
_logger.LogDebug($"{folderPath.Path} hasn't been updated since last scan. Skipping.");
|
||||
continue;
|
||||
}
|
||||
// if (!forceUpdate && Directory.GetLastWriteTime(folderPath.Path) <= folderPath.LastScanned)
|
||||
// {
|
||||
// // NOTE: This solution isn't the best, but it has potential. We need to handle a few other cases so it works great.
|
||||
// _logger.LogDebug($"{folderPath.Path} hasn't been updated since last scan. Skipping.");
|
||||
// skippedFolders += 1;
|
||||
// continue;
|
||||
// }
|
||||
|
||||
try {
|
||||
totalFiles += DirectoryService.TraverseTreeParallelForEach(folderPath.Path, (f) =>
|
||||
@ -81,6 +84,17 @@ namespace API.Services
|
||||
catch (ArgumentException ex) {
|
||||
_logger.LogError(ex, $"The directory '{folderPath}' does not exist");
|
||||
}
|
||||
|
||||
folderPath.LastScanned = DateTime.Now;
|
||||
}
|
||||
|
||||
if (skippedFolders == library.Folders.Count)
|
||||
{
|
||||
_logger.LogInformation("All Folders were skipped due to no modifications to the directories.");
|
||||
_unitOfWork.LibraryRepository.Update(library);
|
||||
_scannedSeries = null;
|
||||
_logger.LogInformation("Processed {0} files in {1} milliseconds for {2}", totalFiles, sw.ElapsedMilliseconds, library.Name);
|
||||
return;
|
||||
}
|
||||
|
||||
var filtered = _scannedSeries.Where(kvp => kvp.Value.Count != 0);
|
||||
@ -92,7 +106,7 @@ namespace API.Services
|
||||
// Remove series that are no longer on disk
|
||||
RemoveSeriesNotOnDisk(allSeries, series, library);
|
||||
|
||||
foreach (var folder in library.Folders) folder.LastScanned = DateTime.Now;
|
||||
//foreach (var folder in library.Folders) folder.LastScanned = DateTime.Now;
|
||||
_unitOfWork.LibraryRepository.Update(library);
|
||||
|
||||
if (Task.Run(() => _unitOfWork.Complete()).Result)
|
||||
@ -185,7 +199,7 @@ namespace API.Services
|
||||
|
||||
if (info == null)
|
||||
{
|
||||
_logger.LogInformation($"Could not parse series from {path}");
|
||||
_logger.LogWarning($"Could not parse from {path}");
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user