From 01a16b718ae732509ac58135e323cee941b9435e Mon Sep 17 00:00:00 2001 From: Gauthier Roebroeck Date: Thu, 29 Jul 2021 16:27:22 +0800 Subject: [PATCH] fix: skip old file hashing tasks if feature is disabled closes #585 --- .../kotlin/org/gotson/komga/domain/service/BookLifecycle.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/service/BookLifecycle.kt b/komga/src/main/kotlin/org/gotson/komga/domain/service/BookLifecycle.kt index 3eed0913a..4a7aeaabf 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/service/BookLifecycle.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/service/BookLifecycle.kt @@ -18,6 +18,7 @@ import org.gotson.komga.domain.persistence.MediaRepository import org.gotson.komga.domain.persistence.ReadListRepository import org.gotson.komga.domain.persistence.ReadProgressRepository import org.gotson.komga.domain.persistence.ThumbnailBookRepository +import org.gotson.komga.infrastructure.configuration.KomgaProperties import org.gotson.komga.infrastructure.hash.Hasher import org.gotson.komga.infrastructure.image.ImageConverter import org.gotson.komga.infrastructure.image.ImageType @@ -44,6 +45,7 @@ class BookLifecycle( private val eventPublisher: EventPublisher, private val transactionTemplate: TransactionTemplate, private val hasher: Hasher, + private val komgaProperties: KomgaProperties, ) { fun analyzeAndPersist(book: Book): Boolean { @@ -67,6 +69,9 @@ class BookLifecycle( } fun hashAndPersist(book: Book) { + if (!komgaProperties.fileHashing) + return logger.info { "File hashing is disabled, it may have changed since the task was submitted, skipping" } + logger.info { "Hash and persist book: $book" } if (book.fileHash.isBlank()) { val hash = hasher.computeHash(book.path)