From 8fbc8fd3d4405b3f8f5be442eda1d5b746ccfac1 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Mon, 8 Jun 2026 20:21:57 +0200 Subject: [PATCH] Fix automatic chapter downloads (#2098) The returned result rows of the inserted chapters did not have the up-to-date "last_modified_at". This caused "downloadNewChapters" to not be able to correctly detect unread chapters. it included the newly inserted ones, leading to exiting early due to having unread chapters. Regression 811e15162b538338a11ce7085167244efcfff8fb fixes #2097 --- .../kotlin/suwayomi/tachidesk/manga/impl/Chapter.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Chapter.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Chapter.kt index 641e386ab..b63b5c7ff 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Chapter.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Chapter.kt @@ -194,7 +194,7 @@ object Chapter { } // new chapters after they have been added to the database for auto downloads - val insertedChapters = mutableListOf() + val insertedChapterIds = mutableListOf() val chaptersToInsert = mutableListOf() // do not yet have an ID from the database val chaptersToUpdate = mutableListOf() @@ -309,7 +309,7 @@ object Chapter { } } } - }.forEach { insertedChapters.add(ChapterTable.toDataClass(it)) } + }.forEach { insertedChapterIds.add(it[ChapterTable.id].value) } } if (chaptersToUpdate.isNotEmpty()) { @@ -354,6 +354,13 @@ object Chapter { } if (manga.inLibrary) { + // We have to query the inserted chapters to get the up-to-date data. I.e. "last_modified_at" is not returned by the insert statement, due to being set by a DB trigger + val insertedChapters = + transaction { + ChapterTable.selectAll().where { ChapterTable.id inList insertedChapterIds }.map( + ChapterTable::toDataClass, + ) + } downloadNewChapters(mangaId, currentLatestChapterNumber, numberOfCurrentChapters, insertedChapters) }