Skip to content

Commit

Permalink
fix(api): read progress modified time could be inaccurate in some cases
Browse files Browse the repository at this point in the history
  • Loading branch information
gotson committed Jan 9, 2025
1 parent 623b2e3 commit 6c3565c
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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" }
}
Expand All @@ -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,
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 6c3565c

Please sign in to comment.