mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-13 15:54:35 -05:00
Feature/update to exposed v0.57.0 (#1150)
* Update to exposed-migrations v3.5.0 * Update to kotlin-logging v7.0.0 * Update to exposed v0.46.0 * Update to exposed v0.47.0 * Update to exposed v0.55.0 * Update to exposed v0.56.0 * Update to exposed v0.57.0
This commit is contained in:
@@ -7,8 +7,8 @@ package suwayomi.tachidesk.manga.controller
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import io.javalin.http.HttpStatus
|
||||
import mu.KotlinLogging
|
||||
import suwayomi.tachidesk.manga.impl.extension.Extension
|
||||
import suwayomi.tachidesk.manga.impl.extension.ExtensionsList
|
||||
import suwayomi.tachidesk.manga.model.dataclass.ExtensionDataClass
|
||||
|
||||
@@ -7,9 +7,9 @@ package suwayomi.tachidesk.manga.controller
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import io.javalin.http.HttpStatus
|
||||
import kotlinx.serialization.json.Json
|
||||
import mu.KotlinLogging
|
||||
import suwayomi.tachidesk.manga.impl.track.Track
|
||||
import suwayomi.tachidesk.manga.model.dataclass.TrackerDataClass
|
||||
import suwayomi.tachidesk.server.JavalinSetup.future
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package suwayomi.tachidesk.manga.controller
|
||||
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import io.javalin.http.HttpStatus
|
||||
import io.javalin.websocket.WsConfig
|
||||
import mu.KotlinLogging
|
||||
import suwayomi.tachidesk.manga.impl.Category
|
||||
import suwayomi.tachidesk.manga.impl.Chapter
|
||||
import suwayomi.tachidesk.manga.impl.update.IUpdater
|
||||
|
||||
@@ -14,7 +14,6 @@ import org.jetbrains.exposed.sql.andWhere
|
||||
import org.jetbrains.exposed.sql.deleteWhere
|
||||
import org.jetbrains.exposed.sql.insert
|
||||
import org.jetbrains.exposed.sql.insertAndGetId
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import org.jetbrains.exposed.sql.update
|
||||
@@ -34,7 +33,7 @@ object Category {
|
||||
if (name.equals(DEFAULT_CATEGORY_NAME, ignoreCase = true)) return -1
|
||||
|
||||
return transaction {
|
||||
if (CategoryTable.select { CategoryTable.name eq name }.firstOrNull() == null) {
|
||||
if (CategoryTable.selectAll().where { CategoryTable.name eq name }.firstOrNull() == null) {
|
||||
val newCategoryId =
|
||||
CategoryTable
|
||||
.insertAndGetId {
|
||||
@@ -85,7 +84,8 @@ object Category {
|
||||
transaction {
|
||||
val categories =
|
||||
CategoryTable
|
||||
.select {
|
||||
.selectAll()
|
||||
.where {
|
||||
CategoryTable.id neq DEFAULT_CATEGORY_ID
|
||||
}.orderBy(CategoryTable.order to SortOrder.ASC)
|
||||
.toMutableList()
|
||||
@@ -126,7 +126,8 @@ object Category {
|
||||
transaction {
|
||||
MangaTable
|
||||
.leftJoin(CategoryMangaTable)
|
||||
.select { MangaTable.inLibrary eq true }
|
||||
.selectAll()
|
||||
.where { MangaTable.inLibrary eq true }
|
||||
.andWhere { CategoryMangaTable.manga.isNull() }
|
||||
.empty()
|
||||
.not()
|
||||
@@ -153,7 +154,7 @@ object Category {
|
||||
|
||||
fun getCategoryById(categoryId: Int): CategoryDataClass? =
|
||||
transaction {
|
||||
CategoryTable.select { CategoryTable.id eq categoryId }.firstOrNull()?.let {
|
||||
CategoryTable.selectAll().where { CategoryTable.id eq categoryId }.firstOrNull()?.let {
|
||||
CategoryTable.toDataClass(it)
|
||||
}
|
||||
}
|
||||
@@ -163,12 +164,14 @@ object Category {
|
||||
if (categoryId == DEFAULT_CATEGORY_ID) {
|
||||
MangaTable
|
||||
.leftJoin(CategoryMangaTable)
|
||||
.select { MangaTable.inLibrary eq true }
|
||||
.selectAll()
|
||||
.where { MangaTable.inLibrary eq true }
|
||||
.andWhere { CategoryMangaTable.manga.isNull() }
|
||||
} else {
|
||||
CategoryMangaTable
|
||||
.leftJoin(MangaTable)
|
||||
.select { CategoryMangaTable.category eq categoryId }
|
||||
.selectAll()
|
||||
.where { CategoryMangaTable.category eq categoryId }
|
||||
.andWhere { MangaTable.inLibrary eq true }
|
||||
}.count().toInt()
|
||||
}
|
||||
@@ -176,7 +179,8 @@ object Category {
|
||||
fun getCategoryMetaMap(categoryId: Int): Map<String, String> =
|
||||
transaction {
|
||||
CategoryMetaTable
|
||||
.select { CategoryMetaTable.ref eq categoryId }
|
||||
.selectAll()
|
||||
.where { CategoryMetaTable.ref eq categoryId }
|
||||
.associate { it[CategoryMetaTable.key] to it[CategoryMetaTable.value] }
|
||||
}
|
||||
|
||||
@@ -188,7 +192,7 @@ object Category {
|
||||
transaction {
|
||||
val meta =
|
||||
transaction {
|
||||
CategoryMetaTable.select { (CategoryMetaTable.ref eq categoryId) and (CategoryMetaTable.key eq key) }
|
||||
CategoryMetaTable.selectAll().where { (CategoryMetaTable.ref eq categoryId) and (CategoryMetaTable.key eq key) }
|
||||
}.firstOrNull()
|
||||
|
||||
if (meta == null) {
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.jetbrains.exposed.sql.deleteWhere
|
||||
import org.jetbrains.exposed.sql.insert
|
||||
import org.jetbrains.exposed.sql.leftJoin
|
||||
import org.jetbrains.exposed.sql.max
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import org.jetbrains.exposed.sql.wrapAsExpression
|
||||
import suwayomi.tachidesk.manga.impl.Category.DEFAULT_CATEGORY_ID
|
||||
@@ -39,7 +39,8 @@ object CategoryManga {
|
||||
|
||||
fun notAlreadyInCategory() =
|
||||
CategoryMangaTable
|
||||
.select {
|
||||
.selectAll()
|
||||
.where {
|
||||
(CategoryMangaTable.category eq categoryId) and (CategoryMangaTable.manga eq mangaId)
|
||||
}.isEmpty()
|
||||
|
||||
@@ -71,16 +72,16 @@ object CategoryManga {
|
||||
val unreadCount =
|
||||
wrapAsExpression<Long>(
|
||||
ChapterTable
|
||||
.slice(
|
||||
.select(
|
||||
ChapterTable.id.count(),
|
||||
).select((ChapterTable.isRead eq false) and (ChapterTable.manga eq MangaTable.id)),
|
||||
).where { ((ChapterTable.isRead eq false) and (ChapterTable.manga eq MangaTable.id)) },
|
||||
)
|
||||
val downloadedCount =
|
||||
wrapAsExpression<Long>(
|
||||
ChapterTable
|
||||
.slice(
|
||||
.select(
|
||||
ChapterTable.id.count(),
|
||||
).select((ChapterTable.isDownloaded eq true) and (ChapterTable.manga eq MangaTable.id)),
|
||||
).where { ((ChapterTable.isDownloaded eq true) and (ChapterTable.manga eq MangaTable.id)) },
|
||||
)
|
||||
|
||||
val chapterCount = ChapterTable.id.count().alias("chapter_count")
|
||||
@@ -104,14 +105,14 @@ object CategoryManga {
|
||||
MangaTable
|
||||
.leftJoin(ChapterTable, { MangaTable.id }, { ChapterTable.manga })
|
||||
.leftJoin(CategoryMangaTable)
|
||||
.slice(columns = selectedColumns)
|
||||
.select { (MangaTable.inLibrary eq true) and CategoryMangaTable.category.isNull() }
|
||||
.select(columns = selectedColumns)
|
||||
.where { (MangaTable.inLibrary eq true) and CategoryMangaTable.category.isNull() }
|
||||
} else {
|
||||
MangaTable
|
||||
.innerJoin(CategoryMangaTable)
|
||||
.leftJoin(ChapterTable, { MangaTable.id }, { ChapterTable.manga })
|
||||
.slice(columns = selectedColumns)
|
||||
.select { (MangaTable.inLibrary eq true) and (CategoryMangaTable.category eq categoryId) }
|
||||
.select(columns = selectedColumns)
|
||||
.where { (MangaTable.inLibrary eq true) and (CategoryMangaTable.category eq categoryId) }
|
||||
}
|
||||
|
||||
// Join with the ChapterTable to fetch the last read chapter for each manga
|
||||
@@ -126,7 +127,8 @@ object CategoryManga {
|
||||
transaction {
|
||||
CategoryMangaTable
|
||||
.innerJoin(CategoryTable)
|
||||
.select {
|
||||
.selectAll()
|
||||
.where {
|
||||
CategoryMangaTable.manga eq mangaId
|
||||
}.orderBy(CategoryTable.order to SortOrder.ASC)
|
||||
.map {
|
||||
@@ -139,7 +141,8 @@ object CategoryManga {
|
||||
transaction {
|
||||
CategoryMangaTable
|
||||
.innerJoin(CategoryTable)
|
||||
.select { CategoryMangaTable.manga inList mangaIDs }
|
||||
.selectAll()
|
||||
.where { CategoryMangaTable.manga inList mangaIDs }
|
||||
.groupBy { it[CategoryMangaTable.manga] }
|
||||
.forEach {
|
||||
val mangaId = it.key.value
|
||||
|
||||
@@ -12,11 +12,11 @@ import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import eu.kanade.tachiyomi.util.chapter.ChapterRecognition
|
||||
import eu.kanade.tachiyomi.util.chapter.ChapterSanitizer.sanitize
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import io.github.reactivecircus.cache4k.Cache
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import kotlinx.serialization.Serializable
|
||||
import mu.KotlinLogging
|
||||
import org.jetbrains.exposed.dao.id.EntityID
|
||||
import org.jetbrains.exposed.sql.Op
|
||||
import org.jetbrains.exposed.sql.SortOrder
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.exposed.sql.and
|
||||
import org.jetbrains.exposed.sql.batchInsert
|
||||
import org.jetbrains.exposed.sql.deleteWhere
|
||||
import org.jetbrains.exposed.sql.insert
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.statements.BatchUpdateStatement
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import org.jetbrains.exposed.sql.update
|
||||
@@ -70,7 +70,8 @@ object Chapter {
|
||||
} else {
|
||||
transaction {
|
||||
ChapterTable
|
||||
.select { ChapterTable.manga eq mangaId }
|
||||
.selectAll()
|
||||
.where { ChapterTable.manga eq mangaId }
|
||||
.orderBy(ChapterTable.sourceOrder to SortOrder.DESC)
|
||||
.map {
|
||||
ChapterTable.toDataClass(it)
|
||||
@@ -80,7 +81,14 @@ object Chapter {
|
||||
}
|
||||
}
|
||||
|
||||
fun getCountOfMangaChapters(mangaId: Int): Int = transaction { ChapterTable.select { ChapterTable.manga eq mangaId }.count().toInt() }
|
||||
fun getCountOfMangaChapters(mangaId: Int): Int =
|
||||
transaction {
|
||||
ChapterTable
|
||||
.selectAll()
|
||||
.where { ChapterTable.manga eq mangaId }
|
||||
.count()
|
||||
.toInt()
|
||||
}
|
||||
|
||||
private suspend fun getSourceChapters(mangaId: Int): List<ChapterDataClass> {
|
||||
val chapterList = fetchChapterList(mangaId)
|
||||
@@ -88,7 +96,8 @@ object Chapter {
|
||||
val dbChapterMap =
|
||||
transaction {
|
||||
ChapterTable
|
||||
.select { ChapterTable.manga eq mangaId }
|
||||
.selectAll()
|
||||
.where { ChapterTable.manga eq mangaId }
|
||||
.associateBy({ it[ChapterTable.url] }, { it })
|
||||
}
|
||||
|
||||
@@ -173,7 +182,8 @@ object Chapter {
|
||||
val chaptersInDb =
|
||||
transaction {
|
||||
ChapterTable
|
||||
.select { ChapterTable.manga eq mangaId }
|
||||
.selectAll()
|
||||
.where { ChapterTable.manga eq mangaId }
|
||||
.map { ChapterTable.toDataClass(it) }
|
||||
.toList()
|
||||
}
|
||||
@@ -533,7 +543,8 @@ object Chapter {
|
||||
val mangaIds =
|
||||
transaction {
|
||||
ChapterTable
|
||||
.select { condition }
|
||||
.selectAll()
|
||||
.where(condition)
|
||||
.map { it[ChapterTable.manga].value }
|
||||
.toSet()
|
||||
}
|
||||
@@ -544,7 +555,8 @@ object Chapter {
|
||||
fun getChaptersMetaMaps(chapterIds: List<EntityID<Int>>): Map<EntityID<Int>, Map<String, String>> =
|
||||
transaction {
|
||||
ChapterMetaTable
|
||||
.select { ChapterMetaTable.ref inList chapterIds }
|
||||
.selectAll()
|
||||
.where { ChapterMetaTable.ref inList chapterIds }
|
||||
.groupBy { it[ChapterMetaTable.ref] }
|
||||
.mapValues { it.value.associate { it[ChapterMetaTable.key] to it[ChapterMetaTable.value] } }
|
||||
.withDefault { emptyMap<String, String>() }
|
||||
@@ -553,7 +565,8 @@ object Chapter {
|
||||
fun getChapterMetaMap(chapter: EntityID<Int>): Map<String, String> =
|
||||
transaction {
|
||||
ChapterMetaTable
|
||||
.select { ChapterMetaTable.ref eq chapter }
|
||||
.selectAll()
|
||||
.where { ChapterMetaTable.ref eq chapter }
|
||||
.associate { it[ChapterMetaTable.key] to it[ChapterMetaTable.value] }
|
||||
}
|
||||
|
||||
@@ -566,7 +579,8 @@ object Chapter {
|
||||
transaction {
|
||||
val chapterId =
|
||||
ChapterTable
|
||||
.select { (ChapterTable.manga eq mangaId) and (ChapterTable.sourceOrder eq chapterIndex) }
|
||||
.selectAll()
|
||||
.where { (ChapterTable.manga eq mangaId) and (ChapterTable.sourceOrder eq chapterIndex) }
|
||||
.first()[ChapterTable.id]
|
||||
.value
|
||||
modifyChapterMeta(chapterId, key, value)
|
||||
@@ -581,7 +595,8 @@ object Chapter {
|
||||
transaction {
|
||||
val meta =
|
||||
ChapterMetaTable
|
||||
.select { (ChapterMetaTable.ref eq chapterId) and (ChapterMetaTable.key eq key) }
|
||||
.selectAll()
|
||||
.where { (ChapterMetaTable.ref eq chapterId) and (ChapterMetaTable.key eq key) }
|
||||
.firstOrNull()
|
||||
|
||||
if (meta == null) {
|
||||
@@ -605,7 +620,8 @@ object Chapter {
|
||||
transaction {
|
||||
val chapterId =
|
||||
ChapterTable
|
||||
.select { (ChapterTable.manga eq mangaId) and (ChapterTable.sourceOrder eq chapterIndex) }
|
||||
.selectAll()
|
||||
.where { (ChapterTable.manga eq mangaId) and (ChapterTable.sourceOrder eq chapterIndex) }
|
||||
.first()[ChapterTable.id]
|
||||
.value
|
||||
|
||||
@@ -627,9 +643,11 @@ object Chapter {
|
||||
transaction {
|
||||
val chapterIds =
|
||||
ChapterTable
|
||||
.slice(ChapterTable.manga, ChapterTable.id)
|
||||
.select { (ChapterTable.sourceOrder inList input.chapterIndexes) and (ChapterTable.manga eq mangaId) }
|
||||
.map { row ->
|
||||
.select(ChapterTable.manga, ChapterTable.id)
|
||||
.where {
|
||||
(ChapterTable.sourceOrder inList input.chapterIndexes) and
|
||||
(ChapterTable.manga eq mangaId)
|
||||
}.map { row ->
|
||||
val chapterId = row[ChapterTable.id].value
|
||||
ChapterDownloadHelper.delete(mangaId, chapterId)
|
||||
|
||||
@@ -646,8 +664,8 @@ object Chapter {
|
||||
fun deleteChapters(chapterIds: List<Int>) {
|
||||
transaction {
|
||||
ChapterTable
|
||||
.slice(ChapterTable.manga, ChapterTable.id)
|
||||
.select { ChapterTable.id inList chapterIds }
|
||||
.select(ChapterTable.manga, ChapterTable.id)
|
||||
.where { ChapterTable.id inList chapterIds }
|
||||
.forEach { row ->
|
||||
val chapterMangaId = row[ChapterTable.manga].value
|
||||
val chapterId = row[ChapterTable.id].value
|
||||
@@ -664,7 +682,8 @@ object Chapter {
|
||||
paginatedFrom(pageNum) {
|
||||
transaction {
|
||||
(ChapterTable innerJoin MangaTable)
|
||||
.select { (MangaTable.inLibrary eq true) and (ChapterTable.fetchedAt greater MangaTable.inLibraryAt) }
|
||||
.selectAll()
|
||||
.where { (MangaTable.inLibrary eq true) and (ChapterTable.fetchedAt greater MangaTable.inLibraryAt) }
|
||||
.orderBy(ChapterTable.fetchedAt to SortOrder.DESC)
|
||||
.map {
|
||||
MangaChapterDataClass(
|
||||
|
||||
@@ -13,7 +13,7 @@ import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.launch
|
||||
import org.jetbrains.exposed.sql.and
|
||||
import org.jetbrains.exposed.sql.insert
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import org.jetbrains.exposed.sql.update
|
||||
import suwayomi.tachidesk.manga.impl.Manga.getManga
|
||||
@@ -31,10 +31,12 @@ object Library {
|
||||
transaction {
|
||||
val defaultCategories =
|
||||
CategoryTable
|
||||
.select {
|
||||
(CategoryTable.isDefault eq true) and (CategoryTable.id neq Category.DEFAULT_CATEGORY_ID)
|
||||
.selectAll()
|
||||
.where {
|
||||
(CategoryTable.isDefault eq true) and
|
||||
(CategoryTable.id neq Category.DEFAULT_CATEGORY_ID)
|
||||
}.toList()
|
||||
val existingCategories = CategoryMangaTable.select { CategoryMangaTable.manga eq mangaId }.toList()
|
||||
val existingCategories = CategoryMangaTable.selectAll().where { CategoryMangaTable.manga eq mangaId }.toList()
|
||||
|
||||
MangaTable.update({ MangaTable.id eq manga.id }) {
|
||||
it[inLibrary] = true
|
||||
|
||||
@@ -15,16 +15,16 @@ import eu.kanade.tachiyomi.source.local.LocalSource
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.source.model.UpdateStrategy
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import io.github.oshai.kotlinlogging.KLogger
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import io.javalin.http.HttpStatus
|
||||
import mu.KLogger
|
||||
import mu.KotlinLogging
|
||||
import okhttp3.CacheControl
|
||||
import okhttp3.Response
|
||||
import org.jetbrains.exposed.sql.ResultRow
|
||||
import org.jetbrains.exposed.sql.SortOrder
|
||||
import org.jetbrains.exposed.sql.and
|
||||
import org.jetbrains.exposed.sql.insert
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import org.jetbrains.exposed.sql.update
|
||||
import suwayomi.tachidesk.manga.impl.MangaList.proxyThumbnailUrl
|
||||
@@ -72,14 +72,14 @@ object Manga {
|
||||
mangaId: Int,
|
||||
onlineFetch: Boolean = false,
|
||||
): MangaDataClass {
|
||||
var mangaEntry = transaction { MangaTable.select { MangaTable.id eq mangaId }.first() }
|
||||
var mangaEntry = transaction { MangaTable.selectAll().where { MangaTable.id eq mangaId }.first() }
|
||||
|
||||
return if (!onlineFetch && mangaEntry[MangaTable.initialized]) {
|
||||
getMangaDataClass(mangaId, mangaEntry)
|
||||
} else { // initialize manga
|
||||
val sManga = fetchManga(mangaId) ?: return getMangaDataClass(mangaId, mangaEntry)
|
||||
|
||||
mangaEntry = transaction { MangaTable.select { MangaTable.id eq mangaId }.first() }
|
||||
mangaEntry = transaction { MangaTable.selectAll().where { MangaTable.id eq mangaId }.first() }
|
||||
|
||||
MangaDataClass(
|
||||
id = mangaId,
|
||||
@@ -109,7 +109,7 @@ object Manga {
|
||||
}
|
||||
|
||||
suspend fun fetchManga(mangaId: Int): SManga? {
|
||||
val mangaEntry = transaction { MangaTable.select { MangaTable.id eq mangaId }.first() }
|
||||
val mangaEntry = transaction { MangaTable.selectAll().where { MangaTable.id eq mangaId }.first() }
|
||||
|
||||
val source =
|
||||
getCatalogueSourceOrNull(mangaEntry[MangaTable.sourceReference])
|
||||
@@ -193,22 +193,26 @@ object Manga {
|
||||
return transaction {
|
||||
val unreadCount =
|
||||
ChapterTable
|
||||
.select { (ChapterTable.manga eq mangaId) and (ChapterTable.isRead eq false) }
|
||||
.selectAll()
|
||||
.where { (ChapterTable.manga eq mangaId) and (ChapterTable.isRead eq false) }
|
||||
.count()
|
||||
|
||||
val downloadCount =
|
||||
ChapterTable
|
||||
.select { (ChapterTable.manga eq mangaId) and (ChapterTable.isDownloaded eq true) }
|
||||
.selectAll()
|
||||
.where { (ChapterTable.manga eq mangaId) and (ChapterTable.isDownloaded eq true) }
|
||||
.count()
|
||||
|
||||
val chapterCount =
|
||||
ChapterTable
|
||||
.select { (ChapterTable.manga eq mangaId) }
|
||||
.selectAll()
|
||||
.where { (ChapterTable.manga eq mangaId) }
|
||||
.count()
|
||||
|
||||
val lastChapterRead =
|
||||
ChapterTable
|
||||
.select { (ChapterTable.manga eq mangaId) }
|
||||
.selectAll()
|
||||
.where { (ChapterTable.manga eq mangaId) }
|
||||
.orderBy(ChapterTable.sourceOrder to SortOrder.DESC)
|
||||
.firstOrNull { it[ChapterTable.isRead] }
|
||||
|
||||
@@ -252,7 +256,8 @@ object Manga {
|
||||
fun getMangaMetaMap(mangaId: Int): Map<String, String> =
|
||||
transaction {
|
||||
MangaMetaTable
|
||||
.select { MangaMetaTable.ref eq mangaId }
|
||||
.selectAll()
|
||||
.where { MangaMetaTable.ref eq mangaId }
|
||||
.associate { it[MangaMetaTable.key] to it[MangaMetaTable.value] }
|
||||
}
|
||||
|
||||
@@ -264,7 +269,8 @@ object Manga {
|
||||
transaction {
|
||||
val meta =
|
||||
MangaMetaTable
|
||||
.select { (MangaMetaTable.ref eq mangaId) and (MangaMetaTable.key eq key) }
|
||||
.selectAll()
|
||||
.where { (MangaMetaTable.ref eq mangaId) and (MangaMetaTable.key eq key) }
|
||||
.firstOrNull()
|
||||
|
||||
if (meta == null) {
|
||||
@@ -284,7 +290,7 @@ object Manga {
|
||||
private suspend fun fetchThumbnailUrl(mangaId: Int): String? {
|
||||
getManga(mangaId, true)
|
||||
return transaction {
|
||||
MangaTable.select { MangaTable.id eq mangaId }.first()
|
||||
MangaTable.selectAll().where { MangaTable.id eq mangaId }.first()
|
||||
}[MangaTable.thumbnail_url]
|
||||
}
|
||||
|
||||
@@ -335,7 +341,7 @@ object Manga {
|
||||
val cacheSaveDir = applicationDirs.tempThumbnailCacheRoot
|
||||
val fileName = mangaId.toString()
|
||||
|
||||
val mangaEntry = transaction { MangaTable.select { MangaTable.id eq mangaId }.first() }
|
||||
val mangaEntry = transaction { MangaTable.selectAll().where { MangaTable.id eq mangaId }.first() }
|
||||
val sourceId = mangaEntry[MangaTable.sourceReference]
|
||||
|
||||
return when (val source = getCatalogueSourceOrStub(sourceId)) {
|
||||
@@ -376,7 +382,7 @@ object Manga {
|
||||
}
|
||||
|
||||
suspend fun getMangaThumbnail(mangaId: Int): Pair<InputStream, String> {
|
||||
val mangaEntry = transaction { MangaTable.select { MangaTable.id eq mangaId }.first() }
|
||||
val mangaEntry = transaction { MangaTable.selectAll().where { MangaTable.id eq mangaId }.first() }
|
||||
|
||||
if (mangaEntry[MangaTable.inLibrary] && mangaEntry[MangaTable.sourceReference] != LocalSource.ID) {
|
||||
return try {
|
||||
@@ -399,13 +405,14 @@ object Manga {
|
||||
|
||||
fun getLatestChapter(mangaId: Int): ChapterDataClass? =
|
||||
transaction {
|
||||
ChapterTable.select { ChapterTable.manga eq mangaId }.maxByOrNull { it[ChapterTable.sourceOrder] }
|
||||
ChapterTable.selectAll().where { ChapterTable.manga eq mangaId }.maxByOrNull { it[ChapterTable.sourceOrder] }
|
||||
}?.let { ChapterTable.toDataClass(it) }
|
||||
|
||||
fun getUnreadChapters(mangaId: Int): List<ChapterDataClass> =
|
||||
transaction {
|
||||
ChapterTable
|
||||
.select { (ChapterTable.manga eq mangaId) and (ChapterTable.isRead eq false) }
|
||||
.selectAll()
|
||||
.where { (ChapterTable.manga eq mangaId) and (ChapterTable.isRead eq false) }
|
||||
.orderBy(ChapterTable.sourceOrder to SortOrder.DESC)
|
||||
.map { ChapterTable.toDataClass(it) }
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import eu.kanade.tachiyomi.source.model.MangasPage
|
||||
import org.jetbrains.exposed.dao.id.EntityID
|
||||
import org.jetbrains.exposed.sql.and
|
||||
import org.jetbrains.exposed.sql.batchInsert
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.statements.BatchUpdateStatement
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import suwayomi.tachidesk.manga.impl.util.source.GetCatalogueSource.getCatalogueSourceOrStub
|
||||
@@ -49,8 +49,10 @@ object MangaList {
|
||||
transaction {
|
||||
val existingMangaUrlsToId =
|
||||
MangaTable
|
||||
.select {
|
||||
(MangaTable.sourceReference eq sourceId) and (MangaTable.url inList mangas.map { it.url })
|
||||
.selectAll()
|
||||
.where {
|
||||
(MangaTable.sourceReference eq sourceId) and
|
||||
(MangaTable.url inList mangas.map { it.url })
|
||||
}.associateBy { it[MangaTable.url] }
|
||||
val existingMangaUrls = existingMangaUrlsToId.map { it.key }
|
||||
|
||||
@@ -123,7 +125,7 @@ object MangaList {
|
||||
val mangaList =
|
||||
transaction {
|
||||
val mangaIds = insertOrUpdate(sourceId)
|
||||
return@transaction MangaTable.select { MangaTable.id inList mangaIds }.map { MangaTable.toDataClass(it) }
|
||||
return@transaction MangaTable.selectAll().where { MangaTable.id inList mangaIds }.map { MangaTable.toDataClass(it) }
|
||||
}
|
||||
return PagedMangaListDataClass(
|
||||
mangaList,
|
||||
|
||||
@@ -13,7 +13,7 @@ import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import org.jetbrains.exposed.sql.SortOrder
|
||||
import org.jetbrains.exposed.sql.and
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import org.jetbrains.exposed.sql.update
|
||||
import suwayomi.tachidesk.manga.impl.util.getChapterCachePath
|
||||
@@ -47,13 +47,15 @@ object Page {
|
||||
index: Int,
|
||||
progressFlow: ((StateFlow<Int>) -> Unit)? = null,
|
||||
): Pair<InputStream, String> {
|
||||
val mangaEntry = transaction { MangaTable.select { MangaTable.id eq mangaId }.first() }
|
||||
val mangaEntry = transaction { MangaTable.selectAll().where { MangaTable.id eq mangaId }.first() }
|
||||
val source = getCatalogueSourceOrStub(mangaEntry[MangaTable.sourceReference])
|
||||
val chapterEntry =
|
||||
transaction {
|
||||
ChapterTable
|
||||
.select {
|
||||
(ChapterTable.sourceOrder eq chapterIndex) and (ChapterTable.manga eq mangaId)
|
||||
.selectAll()
|
||||
.where {
|
||||
(ChapterTable.sourceOrder eq chapterIndex) and
|
||||
(ChapterTable.manga eq mangaId)
|
||||
}.first()
|
||||
}
|
||||
val chapterId = chapterEntry[ChapterTable.id].value
|
||||
@@ -61,7 +63,8 @@ object Page {
|
||||
val pageEntry =
|
||||
transaction {
|
||||
PageTable
|
||||
.select { (PageTable.chapter eq chapterId) }
|
||||
.selectAll()
|
||||
.where { (PageTable.chapter eq chapterId) }
|
||||
.orderBy(PageTable.index to SortOrder.ASC)
|
||||
.limit(1, index.toLong())
|
||||
.first()
|
||||
|
||||
@@ -11,12 +11,11 @@ import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceScreen
|
||||
import eu.kanade.tachiyomi.source.ConfigurableSource
|
||||
import eu.kanade.tachiyomi.source.sourcePreferences
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import io.javalin.json.JsonMapper
|
||||
import io.javalin.json.fromJsonString
|
||||
import mu.KotlinLogging
|
||||
import org.jetbrains.exposed.sql.and
|
||||
import org.jetbrains.exposed.sql.insert
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import org.jetbrains.exposed.sql.update
|
||||
@@ -39,7 +38,7 @@ object Source {
|
||||
return transaction {
|
||||
SourceTable.selectAll().mapNotNull {
|
||||
val catalogueSource = getCatalogueSourceOrNull(it[SourceTable.id].value) ?: return@mapNotNull null
|
||||
val sourceExtension = ExtensionTable.select { ExtensionTable.id eq it[SourceTable.extension] }.first()
|
||||
val sourceExtension = ExtensionTable.selectAll().where { ExtensionTable.id eq it[SourceTable.extension] }.first()
|
||||
|
||||
SourceDataClass(
|
||||
it[SourceTable.id].value.toString(),
|
||||
@@ -57,9 +56,9 @@ object Source {
|
||||
|
||||
fun getSource(sourceId: Long): SourceDataClass? { // all the data extracted fresh form the source instance
|
||||
return transaction {
|
||||
val source = SourceTable.select { SourceTable.id eq sourceId }.firstOrNull() ?: return@transaction null
|
||||
val source = SourceTable.selectAll().where { SourceTable.id eq sourceId }.firstOrNull() ?: return@transaction null
|
||||
val catalogueSource = getCatalogueSourceOrNull(sourceId) ?: return@transaction null
|
||||
val extension = ExtensionTable.select { ExtensionTable.id eq source[SourceTable.extension] }.first()
|
||||
val extension = ExtensionTable.selectAll().where { ExtensionTable.id eq source[SourceTable.extension] }.first()
|
||||
|
||||
SourceDataClass(
|
||||
sourceId.toString(),
|
||||
@@ -160,7 +159,7 @@ object Source {
|
||||
transaction {
|
||||
val meta =
|
||||
transaction {
|
||||
SourceMetaTable.select { (SourceMetaTable.ref eq sourceId) and (SourceMetaTable.key eq key) }
|
||||
SourceMetaTable.selectAll().where { (SourceMetaTable.ref eq sourceId) and (SourceMetaTable.key eq key) }
|
||||
}.firstOrNull()
|
||||
|
||||
if (meta == null) {
|
||||
|
||||
@@ -10,19 +10,18 @@ package suwayomi.tachidesk.manga.impl.backup.proto
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import eu.kanade.tachiyomi.source.model.UpdateStrategy
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.launch
|
||||
import mu.KotlinLogging
|
||||
import okio.Buffer
|
||||
import okio.Sink
|
||||
import okio.buffer
|
||||
import okio.gzip
|
||||
import org.jetbrains.exposed.sql.Query
|
||||
import org.jetbrains.exposed.sql.SortOrder
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import suwayomi.tachidesk.manga.impl.CategoryManga
|
||||
@@ -175,7 +174,7 @@ object ProtoBackupExport : ProtoBackupBase() {
|
||||
fun createBackup(flags: BackupFlags): InputStream {
|
||||
// Create root object
|
||||
|
||||
val databaseManga = transaction { MangaTable.select { MangaTable.inLibrary eq true } }
|
||||
val databaseManga = transaction { MangaTable.selectAll().where { MangaTable.inLibrary eq true } }
|
||||
|
||||
val backup: Backup =
|
||||
transaction {
|
||||
@@ -224,7 +223,8 @@ object ProtoBackupExport : ProtoBackupBase() {
|
||||
val chapters =
|
||||
transaction {
|
||||
ChapterTable
|
||||
.select { ChapterTable.manga eq mangaId }
|
||||
.selectAll()
|
||||
.where { ChapterTable.manga eq mangaId }
|
||||
.orderBy(ChapterTable.sourceOrder to SortOrder.DESC)
|
||||
.map {
|
||||
ChapterTable.toDataClass(it)
|
||||
@@ -306,7 +306,7 @@ object ProtoBackupExport : ProtoBackupBase() {
|
||||
.map { it[MangaTable.sourceReference] }
|
||||
.distinct()
|
||||
.map {
|
||||
val sourceRow = SourceTable.select { SourceTable.id eq it }.firstOrNull()
|
||||
val sourceRow = SourceTable.selectAll().where { SourceTable.id eq it }.firstOrNull()
|
||||
BackupSource(
|
||||
sourceRow?.get(SourceTable.name) ?: "",
|
||||
it,
|
||||
|
||||
@@ -7,6 +7,7 @@ package suwayomi.tachidesk.manga.impl.backup.proto
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -17,7 +18,6 @@ import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import mu.KotlinLogging
|
||||
import okio.buffer
|
||||
import okio.gzip
|
||||
import okio.source
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.exposed.sql.and
|
||||
import org.jetbrains.exposed.sql.batchInsert
|
||||
import org.jetbrains.exposed.sql.insert
|
||||
import org.jetbrains.exposed.sql.insertAndGetId
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import org.jetbrains.exposed.sql.update
|
||||
import suwayomi.tachidesk.graphql.types.toStatus
|
||||
@@ -183,7 +183,8 @@ object ProtoBackupImport : ProtoBackupBase() {
|
||||
backup.backupCategories.associate {
|
||||
val dbCategory =
|
||||
CategoryTable
|
||||
.select { CategoryTable.name eq it.name }
|
||||
.selectAll()
|
||||
.where { CategoryTable.name eq it.name }
|
||||
.firstOrNull()
|
||||
val categoryId =
|
||||
dbCategory?.let { categoryResultRow ->
|
||||
@@ -275,7 +276,8 @@ object ProtoBackupImport : ProtoBackupBase() {
|
||||
val dbManga =
|
||||
transaction {
|
||||
MangaTable
|
||||
.select { (MangaTable.url eq manga.url) and (MangaTable.sourceReference eq manga.source) }
|
||||
.selectAll()
|
||||
.where { (MangaTable.url eq manga.url) and (MangaTable.sourceReference eq manga.source) }
|
||||
.firstOrNull()
|
||||
}
|
||||
|
||||
@@ -362,7 +364,7 @@ object ProtoBackupImport : ProtoBackupBase() {
|
||||
|
||||
// merge chapter data
|
||||
val chaptersLength = chapters.size
|
||||
val dbChapters = ChapterTable.select { ChapterTable.manga eq mangaId }
|
||||
val dbChapters = ChapterTable.selectAll().where { ChapterTable.manga eq mangaId }
|
||||
|
||||
chapters.forEach { chapter ->
|
||||
val dbChapter = dbChapters.find { it[ChapterTable.url] == chapter.url }
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore
|
||||
import okio.buffer
|
||||
import okio.gzip
|
||||
import okio.source
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import suwayomi.tachidesk.manga.impl.backup.proto.models.Backup
|
||||
import suwayomi.tachidesk.manga.impl.track.tracker.TrackerManager
|
||||
@@ -36,7 +36,7 @@ object ProtoBackupValidator {
|
||||
|
||||
val missingSources =
|
||||
transaction {
|
||||
sources.filter { SourceTable.select { SourceTable.id eq it.key }.firstOrNull() == null }
|
||||
sources.filter { SourceTable.selectAll().where { SourceTable.id eq it.key }.firstOrNull() == null }
|
||||
}
|
||||
|
||||
val trackers =
|
||||
|
||||
@@ -9,14 +9,14 @@ package suwayomi.tachidesk.manga.impl.chapter
|
||||
|
||||
import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import mu.KLogger
|
||||
import mu.KotlinLogging
|
||||
import io.github.oshai.kotlinlogging.KLogger
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import org.jetbrains.exposed.sql.ResultRow
|
||||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
|
||||
import org.jetbrains.exposed.sql.and
|
||||
import org.jetbrains.exposed.sql.batchInsert
|
||||
import org.jetbrains.exposed.sql.deleteWhere
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import org.jetbrains.exposed.sql.update
|
||||
import suwayomi.tachidesk.manga.impl.ChapterDownloadHelper
|
||||
@@ -98,7 +98,8 @@ private class ChapterForDownload(
|
||||
optMangaId: Int? = null,
|
||||
) = transaction {
|
||||
ChapterTable
|
||||
.select {
|
||||
.selectAll()
|
||||
.where {
|
||||
if (optChapterId != null) {
|
||||
ChapterTable.id eq optChapterId
|
||||
} else if (optChapterIndex != null && optMangaId != null) {
|
||||
@@ -110,7 +111,7 @@ private class ChapterForDownload(
|
||||
}
|
||||
|
||||
private suspend fun fetchPageList(): List<Page> {
|
||||
val mangaEntry = transaction { MangaTable.select { MangaTable.id eq mangaId }.first() }
|
||||
val mangaEntry = transaction { MangaTable.selectAll().where { MangaTable.id eq mangaId }.first() }
|
||||
val source = getCatalogueSourceOrStub(mangaEntry[MangaTable.sourceReference])
|
||||
|
||||
return source.getPageList(
|
||||
|
||||
@@ -9,6 +9,7 @@ package suwayomi.tachidesk.manga.impl.download
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import io.javalin.websocket.WsContext
|
||||
import io.javalin.websocket.WsMessageContext
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
@@ -26,9 +27,8 @@ import kotlinx.coroutines.flow.onStart
|
||||
import kotlinx.coroutines.flow.sample
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.serialization.Serializable
|
||||
import mu.KotlinLogging
|
||||
import org.jetbrains.exposed.sql.and
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import suwayomi.tachidesk.manga.impl.download.model.DownloadChapter
|
||||
import suwayomi.tachidesk.manga.impl.download.model.DownloadState.Downloading
|
||||
@@ -284,8 +284,8 @@ object DownloadManager {
|
||||
val chapter =
|
||||
transaction {
|
||||
ChapterTable
|
||||
.slice(ChapterTable.id)
|
||||
.select { ChapterTable.manga.eq(mangaId) and ChapterTable.sourceOrder.eq(chapterIndex) }
|
||||
.select(ChapterTable.id)
|
||||
.where { ChapterTable.manga.eq(mangaId) and ChapterTable.sourceOrder.eq(chapterIndex) }
|
||||
.first()
|
||||
}
|
||||
enqueue(EnqueueInput(chapterIds = listOf(chapter[ChapterTable.id].value)))
|
||||
@@ -304,7 +304,8 @@ object DownloadManager {
|
||||
val chapters =
|
||||
transaction {
|
||||
(ChapterTable innerJoin MangaTable)
|
||||
.select { ChapterTable.id inList input.chapterIds }
|
||||
.selectAll()
|
||||
.where { ChapterTable.id inList input.chapterIds }
|
||||
.orderBy(ChapterTable.manga)
|
||||
.orderBy(ChapterTable.sourceOrder)
|
||||
.toList()
|
||||
|
||||
@@ -7,6 +7,8 @@ package suwayomi.tachidesk.manga.impl.download
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
import io.github.oshai.kotlinlogging.KLogger
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Job
|
||||
@@ -15,8 +17,6 @@ import kotlinx.coroutines.currentCoroutineContext
|
||||
import kotlinx.coroutines.ensureActive
|
||||
import kotlinx.coroutines.isActive
|
||||
import kotlinx.coroutines.launch
|
||||
import mu.KLogger
|
||||
import mu.KotlinLogging
|
||||
import org.jetbrains.exposed.sql.and
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import org.jetbrains.exposed.sql.update
|
||||
|
||||
@@ -9,7 +9,7 @@ import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.flow.sample
|
||||
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import suwayomi.tachidesk.manga.impl.Page
|
||||
import suwayomi.tachidesk.manga.impl.download.model.DownloadChapter
|
||||
@@ -141,10 +141,10 @@ abstract class ChaptersFilesProvider<Type : FileType>(
|
||||
createComicInfoFile(
|
||||
downloadCacheFolder.toPath(),
|
||||
transaction {
|
||||
MangaTable.select { MangaTable.id eq mangaId }.first()
|
||||
MangaTable.selectAll().where { MangaTable.id eq mangaId }.first()
|
||||
},
|
||||
transaction {
|
||||
ChapterTable.select { ChapterTable.id eq chapterId }.first()
|
||||
ChapterTable.selectAll().where { ChapterTable.id eq chapterId }.first()
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import eu.kanade.tachiyomi.network.NetworkHelper
|
||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.SourceFactory
|
||||
import mu.KotlinLogging
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import okhttp3.CacheControl
|
||||
import okio.buffer
|
||||
import okio.sink
|
||||
@@ -21,7 +21,7 @@ import okio.source
|
||||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
|
||||
import org.jetbrains.exposed.sql.deleteWhere
|
||||
import org.jetbrains.exposed.sql.insert
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import org.jetbrains.exposed.sql.update
|
||||
import suwayomi.tachidesk.manga.impl.extension.ExtensionsList.extensionTableAsDataClass
|
||||
@@ -101,7 +101,7 @@ object Extension {
|
||||
// if it's installed and we want to update, it first has to be uninstalled
|
||||
val isInstalled =
|
||||
transaction {
|
||||
ExtensionTable.select { ExtensionTable.apkName eq apkName }.firstOrNull()
|
||||
ExtensionTable.selectAll().where { ExtensionTable.apkName eq apkName }.firstOrNull()
|
||||
}?.get(ExtensionTable.isInstalled) ?: false
|
||||
|
||||
val fileNameWithoutType = apkName.substringBefore(".apk")
|
||||
@@ -177,7 +177,7 @@ object Extension {
|
||||
|
||||
// update extension info
|
||||
transaction {
|
||||
if (ExtensionTable.select { ExtensionTable.pkgName eq pkgName }.firstOrNull() == null) {
|
||||
if (ExtensionTable.selectAll().where { ExtensionTable.pkgName eq pkgName }.firstOrNull() == null) {
|
||||
ExtensionTable.insert {
|
||||
it[this.apkName] = apkName
|
||||
it[name] = extensionName
|
||||
@@ -198,7 +198,11 @@ object Extension {
|
||||
}
|
||||
|
||||
val extensionId =
|
||||
ExtensionTable.select { ExtensionTable.pkgName eq pkgName }.first()[ExtensionTable.id].value
|
||||
ExtensionTable
|
||||
.selectAll()
|
||||
.where { ExtensionTable.pkgName eq pkgName }
|
||||
.first()[ExtensionTable.id]
|
||||
.value
|
||||
|
||||
sources.forEach { httpSource ->
|
||||
SourceTable.insert {
|
||||
@@ -293,14 +297,14 @@ object Extension {
|
||||
fun uninstallExtension(pkgName: String) {
|
||||
logger.debug("Uninstalling $pkgName")
|
||||
|
||||
val extensionRecord = transaction { ExtensionTable.select { ExtensionTable.pkgName eq pkgName }.first() }
|
||||
val extensionRecord = transaction { ExtensionTable.selectAll().where { ExtensionTable.pkgName eq pkgName }.first() }
|
||||
val fileNameWithoutType = extensionRecord[ExtensionTable.apkName].substringBefore(".apk")
|
||||
val jarPath = "${applicationDirs.extensionsRoot}/$fileNameWithoutType.jar"
|
||||
val sources =
|
||||
transaction {
|
||||
val extensionId = extensionRecord[ExtensionTable.id].value
|
||||
|
||||
val sources = SourceTable.select { SourceTable.extension eq extensionId }.map { it[SourceTable.id].value }
|
||||
val sources = SourceTable.selectAll().where { SourceTable.extension eq extensionId }.map { it[SourceTable.id].value }
|
||||
|
||||
SourceTable.deleteWhere { SourceTable.extension eq extensionId }
|
||||
|
||||
@@ -349,7 +353,7 @@ object Extension {
|
||||
if (apkName == "localSource") {
|
||||
""
|
||||
} else {
|
||||
transaction { ExtensionTable.select { ExtensionTable.apkName eq apkName }.first() }[ExtensionTable.iconUrl]
|
||||
transaction { ExtensionTable.selectAll().where { ExtensionTable.apkName eq apkName }.first() }[ExtensionTable.iconUrl]
|
||||
}
|
||||
|
||||
val cacheSaveDir = "${applicationDirs.extensionsRoot}/icon"
|
||||
|
||||
@@ -8,9 +8,9 @@ package suwayomi.tachidesk.manga.impl.extension
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
import eu.kanade.tachiyomi.source.local.LocalSource
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import mu.KotlinLogging
|
||||
import org.jetbrains.exposed.dao.id.EntityID
|
||||
import org.jetbrains.exposed.sql.ResultRow
|
||||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.inList
|
||||
|
||||
@@ -11,9 +11,9 @@ import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||
import eu.kanade.tachiyomi.network.awaitSuccess
|
||||
import eu.kanade.tachiyomi.network.parseAs
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.Json
|
||||
import mu.KotlinLogging
|
||||
import suwayomi.tachidesk.manga.impl.util.PackageTools.LIB_VERSION_MAX
|
||||
import suwayomi.tachidesk.manga.impl.util.PackageTools.LIB_VERSION_MIN
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package suwayomi.tachidesk.manga.impl.track
|
||||
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.serialization.Serializable
|
||||
import mu.KotlinLogging
|
||||
import org.jetbrains.exposed.sql.ResultRow
|
||||
import org.jetbrains.exposed.sql.SortOrder
|
||||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
|
||||
import org.jetbrains.exposed.sql.and
|
||||
import org.jetbrains.exposed.sql.deleteWhere
|
||||
import org.jetbrains.exposed.sql.insertAndGetId
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import org.jetbrains.exposed.sql.update
|
||||
import suwayomi.tachidesk.manga.impl.track.tracker.DeletableTrackService
|
||||
@@ -75,7 +75,8 @@ object Track {
|
||||
val recordMap =
|
||||
transaction {
|
||||
TrackRecordTable
|
||||
.select { TrackRecordTable.mangaId eq mangaId }
|
||||
.selectAll()
|
||||
.where { TrackRecordTable.mangaId eq mangaId }
|
||||
.map { it.toTrackRecordDataClass() }
|
||||
}.associateBy { it.trackerId }
|
||||
|
||||
@@ -138,7 +139,8 @@ object Track {
|
||||
val track =
|
||||
transaction {
|
||||
TrackSearchTable
|
||||
.select {
|
||||
.selectAll()
|
||||
.where {
|
||||
TrackSearchTable.trackerId eq trackerId and
|
||||
(TrackSearchTable.remoteId eq remoteId)
|
||||
}.first()
|
||||
@@ -162,7 +164,8 @@ object Track {
|
||||
val oldestChapter =
|
||||
transaction {
|
||||
ChapterTable
|
||||
.select {
|
||||
.selectAll()
|
||||
.where {
|
||||
(ChapterTable.manga eq mangaId) and (ChapterTable.isRead eq true)
|
||||
}.orderBy(ChapterTable.lastReadAt to SortOrder.ASC)
|
||||
.limit(1)
|
||||
@@ -186,7 +189,7 @@ object Track {
|
||||
suspend fun refresh(recordId: Int) {
|
||||
val recordDb =
|
||||
transaction {
|
||||
TrackRecordTable.select { TrackRecordTable.id eq recordId }.first()
|
||||
TrackRecordTable.selectAll().where { TrackRecordTable.id eq recordId }.first()
|
||||
}
|
||||
|
||||
val tracker = TrackerManager.getTracker(recordDb[TrackRecordTable.trackerId])!!
|
||||
@@ -202,7 +205,7 @@ object Track {
|
||||
) {
|
||||
val recordDb =
|
||||
transaction {
|
||||
TrackRecordTable.select { TrackRecordTable.id eq recordId }.first()
|
||||
TrackRecordTable.selectAll().where { TrackRecordTable.id eq recordId }.first()
|
||||
}
|
||||
|
||||
val tracker = TrackerManager.getTracker(recordDb[TrackRecordTable.trackerId])
|
||||
@@ -223,7 +226,7 @@ object Track {
|
||||
}
|
||||
val recordDb =
|
||||
transaction {
|
||||
TrackRecordTable.select { TrackRecordTable.id eq input.recordId }.first()
|
||||
TrackRecordTable.selectAll().where { TrackRecordTable.id eq input.recordId }.first()
|
||||
}
|
||||
|
||||
val tracker = TrackerManager.getTracker(recordDb[TrackRecordTable.trackerId])!!
|
||||
@@ -294,7 +297,8 @@ object Track {
|
||||
private fun queryMaxReadChapter(mangaId: Int): ResultRow? =
|
||||
transaction {
|
||||
ChapterTable
|
||||
.select { (ChapterTable.manga eq mangaId) and (ChapterTable.isRead eq true) }
|
||||
.selectAll()
|
||||
.where { (ChapterTable.manga eq mangaId) and (ChapterTable.isRead eq true) }
|
||||
.orderBy(ChapterTable.chapter_number to SortOrder.DESC)
|
||||
.limit(1)
|
||||
.firstOrNull()
|
||||
@@ -307,7 +311,8 @@ object Track {
|
||||
val records =
|
||||
transaction {
|
||||
TrackRecordTable
|
||||
.select { TrackRecordTable.mangaId eq mangaId }
|
||||
.selectAll()
|
||||
.where { TrackRecordTable.mangaId eq mangaId }
|
||||
.toList()
|
||||
}
|
||||
|
||||
@@ -365,7 +370,8 @@ object Track {
|
||||
transaction {
|
||||
val existingRecord =
|
||||
TrackRecordTable
|
||||
.select {
|
||||
.selectAll()
|
||||
.where {
|
||||
(TrackRecordTable.mangaId eq track.manga_id) and
|
||||
(TrackRecordTable.trackerId eq track.sync_id)
|
||||
}.singleOrNull()
|
||||
|
||||
@@ -2,7 +2,7 @@ package suwayomi.tachidesk.manga.impl.track.tracker
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import mu.KotlinLogging
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import suwayomi.tachidesk.manga.impl.track.tracker.anilist.Anilist
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package suwayomi.tachidesk.manga.impl.track.tracker.anilist
|
||||
|
||||
import android.annotation.StringRes
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import mu.KotlinLogging
|
||||
import suwayomi.tachidesk.manga.impl.track.tracker.DeletableTrackService
|
||||
import suwayomi.tachidesk.manga.impl.track.tracker.Tracker
|
||||
import suwayomi.tachidesk.manga.impl.track.tracker.extractToken
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package suwayomi.tachidesk.manga.impl.track.tracker.myanimelist
|
||||
|
||||
import android.annotation.StringRes
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import mu.KotlinLogging
|
||||
import suwayomi.tachidesk.manga.impl.track.tracker.DeletableTrackService
|
||||
import suwayomi.tachidesk.manga.impl.track.tracker.Tracker
|
||||
import suwayomi.tachidesk.manga.impl.track.tracker.extractToken
|
||||
|
||||
@@ -3,6 +3,7 @@ package suwayomi.tachidesk.manga.impl.update
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import eu.kanade.tachiyomi.source.model.UpdateStrategy
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
@@ -27,7 +28,6 @@ import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.sync.Semaphore
|
||||
import kotlinx.coroutines.sync.withPermit
|
||||
import mu.KotlinLogging
|
||||
import suwayomi.tachidesk.manga.impl.Category
|
||||
import suwayomi.tachidesk.manga.impl.CategoryManga
|
||||
import suwayomi.tachidesk.manga.impl.Chapter
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package suwayomi.tachidesk.manga.impl.update
|
||||
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import io.javalin.websocket.WsContext
|
||||
import io.javalin.websocket.WsMessageContext
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
@@ -8,7 +9,6 @@ import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import mu.KotlinLogging
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
object UpdaterSocket : Websocket<UpdateStatus>() {
|
||||
|
||||
@@ -7,7 +7,7 @@ package suwayomi.tachidesk.manga.impl.util
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
import mu.KotlinLogging
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import org.objectweb.asm.ClassReader
|
||||
import org.objectweb.asm.ClassVisitor
|
||||
import org.objectweb.asm.ClassWriter
|
||||
|
||||
@@ -8,7 +8,7 @@ package suwayomi.tachidesk.manga.impl.util
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
import org.jetbrains.exposed.sql.ResultRow
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import suwayomi.tachidesk.manga.impl.util.source.GetCatalogueSource
|
||||
import suwayomi.tachidesk.manga.model.table.ChapterTable
|
||||
@@ -33,7 +33,7 @@ private fun getChapterDir(
|
||||
mangaId: Int,
|
||||
chapterId: Int,
|
||||
): String {
|
||||
val chapterEntry = transaction { ChapterTable.select { ChapterTable.id eq chapterId }.first() }
|
||||
val chapterEntry = transaction { ChapterTable.selectAll().where { ChapterTable.id eq chapterId }.first() }
|
||||
|
||||
val chapterDir =
|
||||
SafePath.buildValidFilename(
|
||||
@@ -91,4 +91,4 @@ fun updateMangaDownloadDir(
|
||||
}
|
||||
}
|
||||
|
||||
private fun getMangaEntry(mangaId: Int): ResultRow = transaction { MangaTable.select { MangaTable.id eq mangaId }.first() }
|
||||
private fun getMangaEntry(mangaId: Int): ResultRow = transaction { MangaTable.selectAll().where { MangaTable.id eq mangaId }.first() }
|
||||
|
||||
@@ -6,7 +6,7 @@ import eu.kanade.tachiyomi.source.local.metadata.ComicInfoPublishingStatus
|
||||
import nl.adaptivity.xmlutil.serialization.XML
|
||||
import org.jetbrains.exposed.sql.ResultRow
|
||||
import org.jetbrains.exposed.sql.SortOrder
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import suwayomi.tachidesk.manga.model.table.CategoryMangaTable
|
||||
import suwayomi.tachidesk.manga.model.table.CategoryTable
|
||||
@@ -77,7 +77,8 @@ fun createComicInfoFile(
|
||||
transaction {
|
||||
CategoryMangaTable
|
||||
.innerJoin(CategoryTable)
|
||||
.select {
|
||||
.selectAll()
|
||||
.where {
|
||||
CategoryMangaTable.manga eq manga[MangaTable.id]
|
||||
}.orderBy(CategoryTable.order to SortOrder.ASC)
|
||||
.map {
|
||||
|
||||
@@ -14,7 +14,7 @@ import com.googlecode.d2j.dex.Dex2jar
|
||||
import com.googlecode.d2j.reader.MultiDexFileReader
|
||||
import com.googlecode.dex2jar.tools.BaksmaliBaseDexExceptionHandler
|
||||
import eu.kanade.tachiyomi.util.lang.Hash
|
||||
import mu.KotlinLogging
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import net.dongliu.apk.parser.ApkFile
|
||||
import net.dongliu.apk.parser.ApkParsers
|
||||
import org.w3c.dom.Element
|
||||
|
||||
@@ -11,8 +11,8 @@ import eu.kanade.tachiyomi.source.CatalogueSource
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.SourceFactory
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import mu.KotlinLogging
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import suwayomi.tachidesk.manga.impl.util.PackageTools.loadExtensionSources
|
||||
import suwayomi.tachidesk.manga.model.table.ExtensionTable
|
||||
@@ -35,13 +35,13 @@ object GetCatalogueSource {
|
||||
|
||||
val sourceRecord =
|
||||
transaction {
|
||||
SourceTable.select { SourceTable.id eq sourceId }.firstOrNull()
|
||||
SourceTable.selectAll().where { SourceTable.id eq sourceId }.firstOrNull()
|
||||
} ?: return null
|
||||
|
||||
val extensionId = sourceRecord[SourceTable.extension]
|
||||
val extensionRecord =
|
||||
transaction {
|
||||
ExtensionTable.select { ExtensionTable.id eq extensionId }.first()
|
||||
ExtensionTable.selectAll().where { ExtensionTable.id eq extensionId }.first()
|
||||
}
|
||||
|
||||
val apkName = extensionRecord[ExtensionTable.apkName]
|
||||
|
||||
@@ -10,7 +10,7 @@ package suwayomi.tachidesk.manga.model.table
|
||||
import org.jetbrains.exposed.dao.id.IntIdTable
|
||||
import org.jetbrains.exposed.sql.ReferenceOption
|
||||
import org.jetbrains.exposed.sql.ResultRow
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import suwayomi.tachidesk.manga.impl.Chapter.getChapterMetaMap
|
||||
import suwayomi.tachidesk.manga.model.dataclass.ChapterDataClass
|
||||
@@ -59,6 +59,13 @@ fun ChapterTable.toDataClass(chapterEntry: ResultRow) =
|
||||
realUrl = chapterEntry[realUrl],
|
||||
downloaded = chapterEntry[isDownloaded],
|
||||
pageCount = chapterEntry[pageCount],
|
||||
chapterCount = transaction { ChapterTable.select { manga eq chapterEntry[manga].value }.count().toInt() },
|
||||
chapterCount =
|
||||
transaction {
|
||||
ChapterTable
|
||||
.selectAll()
|
||||
.where { manga eq chapterEntry[manga].value }
|
||||
.count()
|
||||
.toInt()
|
||||
},
|
||||
meta = getChapterMetaMap(chapterEntry[id]),
|
||||
)
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.jetbrains.exposed.dao.id.IntIdTable
|
||||
import org.jetbrains.exposed.sql.ResultRow
|
||||
import org.jetbrains.exposed.sql.and
|
||||
import org.jetbrains.exposed.sql.batchInsert
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.selectAll
|
||||
import org.jetbrains.exposed.sql.statements.BatchUpdateStatement
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import suwayomi.tachidesk.manga.impl.track.tracker.model.TrackSearch
|
||||
@@ -38,8 +38,10 @@ fun List<TrackSearch>.insertAll(): List<ResultRow> {
|
||||
val existing =
|
||||
transaction {
|
||||
TrackSearchTable
|
||||
.select {
|
||||
TrackSearchTable.trackerId inList trackerIds and (TrackSearchTable.remoteId inList remoteIds)
|
||||
.selectAll()
|
||||
.where {
|
||||
TrackSearchTable.trackerId inList trackerIds and
|
||||
(TrackSearchTable.remoteId inList remoteIds)
|
||||
}.toList()
|
||||
}
|
||||
|
||||
@@ -95,7 +97,7 @@ fun List<TrackSearch>.insertAll(): List<ResultRow> {
|
||||
toUpdate
|
||||
?.mapNotNull { it.first }
|
||||
?.let { ids ->
|
||||
transaction { TrackSearchTable.select { TrackSearchTable.id inList ids }.toList() }
|
||||
transaction { TrackSearchTable.selectAll().where { TrackSearchTable.id inList ids }.toList() }
|
||||
}.orEmpty()
|
||||
|
||||
(insertedRows + updatedRows)
|
||||
|
||||
Reference in New Issue
Block a user