More Scanner Work (#2994)

This commit is contained in:
Joe Milazzo 2024-06-10 15:10:00 -05:00 committed by GitHub
parent 1de426070b
commit 982253f1b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 5 deletions

View File

@ -2118,7 +2118,8 @@ public class SeriesRepository : ISeriesRepository
LowestFolderPath = s.LowestFolderPath,
Format = s.Format,
LibraryRoots = s.Library.Folders.Select(f => f.Path)
}).ToListAsync();
})
.ToListAsync();
var map = new Dictionary<string, IList<SeriesModified>>();
foreach (var series in info)
@ -2137,7 +2138,7 @@ public class SeriesRepository : ISeriesRepository
}
if (string.IsNullOrEmpty(series.LowestFolderPath)) continue;
if (string.IsNullOrEmpty(series.LowestFolderPath) || series.FolderPath.Equals(series.LowestFolderPath)) continue;
if (!map.TryGetValue(series.LowestFolderPath, out var value2))
{
map.Add(series.LowestFolderPath, new List<SeriesModified>()

View File

@ -145,14 +145,16 @@ public class ParseScannedFiles
}
result.Add(CreateScanResult(directory, folderPath, false, ArraySegment<string>.Empty));
}
else if (seriesPaths.TryGetValue(directory, out var series) && series.All(s => !string.IsNullOrEmpty(s.LowestFolderPath)))
else if (!forceCheck && seriesPaths.TryGetValue(directory, out var series) && series.Count > 1 && series.All(s => !string.IsNullOrEmpty(s.LowestFolderPath)))
{
// If there are multiple series inside this path, let's check each of them to see which was modified and only scan those
// This is very helpful for ComicVine libraries by Publisher
_logger.LogDebug("[ProcessFiles] {Directory} is dirty and has multiple series folders, checking if we can avoid a full scan", directory);
foreach (var seriesModified in series)
{
var hasFolderChangedSinceLastScan = library.LastScanned.Truncate(TimeSpan.TicksPerSecond) <
// TODO: We can check directly against seriesModified.LastScanned instead of library scan
var hasFolderChangedSinceLastScan = forceCheck || library.LastScanned.Truncate(TimeSpan.TicksPerSecond) <
_directoryService
.GetLastWriteTime(seriesModified.LowestFolderPath!)
.Truncate(TimeSpan.TicksPerSecond);
@ -167,7 +169,7 @@ public class ParseScannedFiles
}
else
{
_logger.LogDebug("[ProcessFiles] {Directory} subfolder {Folder} changed, adding folders", directory, seriesModified.LowestFolderPath);
_logger.LogDebug("[ProcessFiles] {Directory} subfolder {Folder} changed for Series {SeriesName}", directory, seriesModified.LowestFolderPath, seriesModified.SeriesName);
result.Add(CreateScanResult(directory, folderPath, true,
_directoryService.ScanFiles(seriesModified.LowestFolderPath!, fileExtensions, matcher)));
}