From 036806016691e748ee99decec7c7f3ea41405125 Mon Sep 17 00:00:00 2001 From: Gauthier Roebroeck Date: Fri, 4 Feb 2022 11:51:33 +0800 Subject: [PATCH] fix: a TooManyRowsException may crash the scan --- .../kotlin/org/gotson/komga/infrastructure/jooq/BookDao.kt | 4 +++- .../kotlin/org/gotson/komga/infrastructure/jooq/SeriesDao.kt | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/BookDao.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/BookDao.kt index 66a4b5979..5293f58d4 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/BookDao.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/BookDao.kt @@ -43,7 +43,9 @@ class BookDao( dsl.selectFrom(b) .where(b.LIBRARY_ID.eq(libraryId).and(b.URL.eq(url.toString()))) .and(b.DELETED_DATE.isNull) - .fetchOneInto(b) + .orderBy(b.LAST_MODIFIED_DATE.desc()) + .fetchInto(b) + .firstOrNull() ?.toDomain() private fun findByIdOrNull(dsl: DSLContext, bookId: String): Book? = diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/SeriesDao.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/SeriesDao.kt index a52e70c8e..70044f209 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/SeriesDao.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/SeriesDao.kt @@ -58,7 +58,9 @@ class SeriesDao( dsl.selectFrom(s) .where(s.LIBRARY_ID.eq(libraryId).and(s.URL.eq(url.toString()))) .and(s.DELETED_DATE.isNull) - .fetchOneInto(s) + .orderBy(s.LAST_MODIFIED_DATE.desc()) + .fetchInto(s) + .firstOrNull() ?.toDomain() override fun findAllByTitle(title: String): Collection =