diff --git a/core/src/filesystem/scanner/library_scan_job.rs b/core/src/filesystem/scanner/library_scan_job.rs index 8d66b4620..4c1aea05e 100644 --- a/core/src/filesystem/scanner/library_scan_job.rs +++ b/core/src/filesystem/scanner/library_scan_job.rs @@ -397,10 +397,16 @@ impl JobExt for LibraryScanJob { // If the library is not collection-priority, each subdirectory is its own series. // Therefore, we only scan one level deep when walking a series whose library is not // collection-priority to avoid scanning duplicates which are part of other series - let max_depth = self + let mut max_depth = self .options .as_ref() .and_then(|o| (!o.is_collection_based()).then_some(1)); + if path_buf == PathBuf::from(&self.path) { + // The exception is when the series "is" the libray (i.e. the root of the library contains + // books). This is kind of an anti-pattern wrt collection-priority, but it needs to be handled + // in order to avoid the scanner re-scanning the entire library... + max_depth = Some(1); + } let Some(Ok(ignore_rules)) = self.options.as_ref().map(|o| o.ignore_rules.build()) diff --git a/core/src/filesystem/scanner/series_scan_job.rs b/core/src/filesystem/scanner/series_scan_job.rs index cc16b7cac..19fdc6905 100644 --- a/core/src/filesystem/scanner/series_scan_job.rs +++ b/core/src/filesystem/scanner/series_scan_job.rs @@ -96,6 +96,7 @@ impl JobExt for SeriesScanJob { ctx: &WorkerCtx, ) -> Result, JobError> { let mut output = Self::Output::default(); + let path_buf = PathBuf::from(self.path.clone()); let library = ctx .db .library() @@ -117,7 +118,13 @@ impl JobExt for SeriesScanJob { // If the library is not collection-priority, each subdirectory is its own series. // Therefore, we only scan one level deep when walking a series whose library is not // collection-priority to avoid scanning duplicates which are part of other series - let max_depth = (!library_config.is_collection_based()).then_some(1); + let mut max_depth = (!library_config.is_collection_based()).then_some(1); + if path_buf == PathBuf::from(&library.path) { + // The exception is when the series "is" the libray (i.e. the root of the library contains + // books). This is kind of an anti-pattern wrt collection-priority, but it needs to be handled + // in order to avoid the scanner re-scanning the entire library... + max_depth = Some(1); + } self.options = Some(library_config);