From 6c3565caa831330e39f67f78bb9cc70225fcf188 Mon Sep 17 00:00:00 2001 From: Gauthier Roebroeck Date: Thu, 9 Jan 2025 15:39:20 +0800 Subject: [PATCH] fix(api): read progress modified time could be inaccurate in some cases --- .../org/gotson/komga/domain/service/BookLifecycle.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 5d7fc605d4..a1629e659a 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 @@ -34,7 +34,6 @@ import org.gotson.komga.infrastructure.hash.Hasher import org.gotson.komga.infrastructure.hash.KoreaderHasher import org.gotson.komga.infrastructure.image.ImageConverter import org.gotson.komga.infrastructure.image.ImageType -import org.gotson.komga.language.toCurrentTimeZone import org.springframework.beans.factory.annotation.Qualifier import org.springframework.context.ApplicationEventPublisher import org.springframework.data.domain.Pageable @@ -43,6 +42,7 @@ import org.springframework.transaction.support.TransactionTemplate import org.springframework.web.util.UriUtils import java.io.File import java.time.LocalDateTime +import java.time.ZoneId import kotlin.io.path.deleteIfExists import kotlin.io.path.exists import kotlin.io.path.isWritable @@ -458,8 +458,8 @@ class BookLifecycle( readProgressRepository.findByBookIdAndUserIdOrNull(book.id, user.id)?.let { savedProgress -> check( newProgression.modified + .withZoneSameInstant(ZoneId.systemDefault()) .toLocalDateTime() - .toCurrentTimeZone() .isAfter(savedProgress.readDate), ) { "Progression is older than existing" } } @@ -477,7 +477,7 @@ class BookLifecycle( user.id, newProgression.locator.locations!!.position!!, newProgression.locator.locations.position == media.pageCount, - newProgression.modified.toLocalDateTime().toCurrentTimeZone(), + newProgression.modified.withZoneSameInstant(ZoneId.systemDefault()).toLocalDateTime(), newProgression.device.id, newProgression.device.name, newProgression.locator, @@ -518,7 +518,7 @@ class BookLifecycle( user.id, totalProgression?.let { (media.pageCount * it).roundToInt() } ?: 0, totalProgression?.let { it >= 0.99F } ?: false, - newProgression.modified.toLocalDateTime().toCurrentTimeZone(), + newProgression.modified.withZoneSameInstant(ZoneId.systemDefault()).toLocalDateTime(), newProgression.device.id, newProgression.device.name, newProgression.locator.copy(