diff --git a/API/Data/Repositories/SeriesRepository.cs b/API/Data/Repositories/SeriesRepository.cs index 2ca93d1f0..3b6ed9bb6 100644 --- a/API/Data/Repositories/SeriesRepository.cs +++ b/API/Data/Repositories/SeriesRepository.cs @@ -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>(); 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() diff --git a/API/Services/Tasks/Scanner/ParseScannedFiles.cs b/API/Services/Tasks/Scanner/ParseScannedFiles.cs index f9b018508..2fd4c9e0b 100644 --- a/API/Services/Tasks/Scanner/ParseScannedFiles.cs +++ b/API/Services/Tasks/Scanner/ParseScannedFiles.cs @@ -145,14 +145,16 @@ public class ParseScannedFiles } result.Add(CreateScanResult(directory, folderPath, false, ArraySegment.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))); }