mirror of
https://github.com/gotson/komga.git
synced 2026-05-08 21:00:16 +02:00
perf(komga): only rescan library on update when relevant
This commit is contained in:
parent
c6c7c89a84
commit
b48c113bb3
1 changed files with 12 additions and 1 deletions
|
|
@ -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<Library>) {
|
||||
if (!Files.exists(library.path))
|
||||
throw FileNotFoundException("Library root folder does not exist: ${library.root}")
|
||||
|
|
|
|||
Loading…
Reference in a new issue