fix meta update changing all keys (#314)

This commit is contained in:
Aria Moradi
2022-03-18 00:14:22 +03:30
committed by GitHub
parent 186ace4343
commit fa035ad9be
2 changed files with 13 additions and 7 deletions

View File

@@ -201,8 +201,10 @@ object Chapter {
val chapterId =
ChapterTable.select { (ChapterTable.manga eq mangaId) and (ChapterTable.sourceOrder eq chapterIndex) }
.first()[ChapterTable.id].value
val meta =
transaction { ChapterMetaTable.select { (ChapterMetaTable.ref eq chapterId) and (ChapterMetaTable.key eq key) } }.firstOrNull()
val meta = transaction {
ChapterMetaTable.select { (ChapterMetaTable.ref eq chapterId) and (ChapterMetaTable.key eq key) }
}.firstOrNull()
if (meta == null) {
ChapterMetaTable.insert {
it[ChapterMetaTable.key] = key
@@ -210,7 +212,7 @@ object Chapter {
it[ChapterMetaTable.ref] = chapterId
}
} else {
ChapterMetaTable.update {
ChapterMetaTable.update({ (ChapterMetaTable.ref eq chapterId) and (ChapterMetaTable.key eq key) }) {
it[ChapterMetaTable.value] = value
}
}

View File

@@ -146,8 +146,10 @@ object Manga {
transaction {
val manga = MangaTable.select { MangaTable.id eq mangaId }
.first()[MangaTable.id]
val meta =
transaction { MangaMetaTable.select { (MangaMetaTable.ref eq manga) and (MangaMetaTable.key eq key) } }.firstOrNull()
val meta = transaction {
MangaMetaTable.select { (MangaMetaTable.ref eq manga) and (MangaMetaTable.key eq key) }
}.firstOrNull()
if (meta == null) {
MangaMetaTable.insert {
it[MangaMetaTable.key] = key
@@ -155,7 +157,7 @@ object Manga {
it[MangaMetaTable.ref] = manga
}
} else {
MangaMetaTable.update {
MangaMetaTable.update({ (MangaMetaTable.ref eq manga) and (MangaMetaTable.key eq key) }) {
it[MangaMetaTable.value] = value
}
}
@@ -176,7 +178,9 @@ object Manga {
?: if (!mangaEntry[MangaTable.initialized]) {
// initialize then try again
getManga(mangaId)
transaction { MangaTable.select { MangaTable.id eq mangaId }.first() }[MangaTable.thumbnail_url]!!
transaction {
MangaTable.select { MangaTable.id eq mangaId }.first()
}[MangaTable.thumbnail_url]!!
} else {
// source provides no thumbnail url for this manga
throw NullPointerException()