diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/ChapterMutation.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/ChapterMutation.kt index b42cab68..40dda6b0 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/ChapterMutation.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/ChapterMutation.kt @@ -228,7 +228,9 @@ class ChapterMutation { this[PageTable.chapter] = chapterId } ChapterTable.update({ ChapterTable.id eq chapterId }) { - it[ChapterTable.pageCount] = pageList.size + val pageCount = pageList.size + it[ChapterTable.pageCount] = pageCount + it[ChapterTable.lastPageRead] = chapter[ChapterTable.lastPageRead].coerceAtMost(pageCount - 1) } } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/chapter/ChapterForDownload.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/chapter/ChapterForDownload.kt index 622e4d91..b184dea1 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/chapter/ChapterForDownload.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/chapter/ChapterForDownload.kt @@ -118,8 +118,11 @@ private class ChapterForDownload( val pageCount = pageList.count() transaction { + val lastPageRead = ChapterTable.select { ChapterTable.id eq chapterId }.firstOrNull()?.get(ChapterTable.lastPageRead) ?: 0 + ChapterTable.update({ ChapterTable.id eq chapterId }) { it[ChapterTable.pageCount] = pageCount + it[ChapterTable.lastPageRead] = lastPageRead.coerceAtMost(pageCount - 1) } } }