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) }