Skip to content

Commit

Permalink
🐛 Fix root-level books in collection libraries (#493)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronleopold authored Oct 30, 2024
1 parent a3a8c85 commit 99703d2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 7 additions & 1 deletion core/src/filesystem/scanner/library_scan_job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
9 changes: 8 additions & 1 deletion core/src/filesystem/scanner/series_scan_job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ impl JobExt for SeriesScanJob {
ctx: &WorkerCtx,
) -> Result<WorkingState<Self::Output, Self::Task>, JobError> {
let mut output = Self::Output::default();
let path_buf = PathBuf::from(self.path.clone());
let library = ctx
.db
.library()
Expand All @@ -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);

Expand Down

0 comments on commit 99703d2

Please sign in to comment.