diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/service/LibraryLifecycle.kt b/komga/src/main/kotlin/org/gotson/komga/domain/service/LibraryLifecycle.kt index a24a0d72..ef17202b 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/service/LibraryLifecycle.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/service/LibraryLifecycle.kt @@ -64,11 +64,22 @@ class LibraryLifecycle( if (current.scanInterval != toUpdate.scanInterval) libraryScanScheduler.scheduleScan(toUpdate) - taskEmitter.scanLibrary(toUpdate.id) + if (checkLibraryShouldRescan(current, toUpdate)) + taskEmitter.scanLibrary(toUpdate.id) eventPublisher.publishEvent(DomainEvent.LibraryUpdated(toUpdate)) } + private fun checkLibraryShouldRescan(existing: Library, updated: Library): Boolean { + if (existing.root != updated.root) return true + if (existing.oneshotsDirectory != updated.oneshotsDirectory) return true + if (existing.scanCbx != updated.scanCbx) return true + if (existing.scanPdf != updated.scanPdf) return true + if (existing.scanEpub != updated.scanEpub) return true + if (existing.scanForceModifiedTime != updated.scanForceModifiedTime) return true + return false + } + private fun checkLibraryValidity(library: Library, existing: Collection) { if (!Files.exists(library.path)) throw FileNotFoundException("Library root folder does not exist: ${library.root}")