Fix pages after refactoring downloads (#1639)

This commit is contained in:
Mitchell Syer
2025-09-09 21:10:27 -04:00
committed by GitHub
parent c1a9b158e2
commit 3f4dd2861e
2 changed files with 31 additions and 17 deletions

View File

@@ -466,8 +466,14 @@ object MangaController {
behaviorOf = { ctx, mangaId, chapterIndex, index, updateProgress, format -> behaviorOf = { ctx, mangaId, chapterIndex, index, updateProgress, format ->
ctx.getAttribute(Attribute.TachideskUser).requireUser() ctx.getAttribute(Attribute.TachideskUser).requireUser()
ctx.future { ctx.future {
future { Page.getPageImage(mangaId, chapterIndex, index, format, null) } future {
.thenApply { Page.getPageImage(
mangaId = mangaId,
chapterIndex = chapterIndex,
index = index,
format = format,
)
}.thenApply {
ctx.header("content-type", it.second) ctx.header("content-type", it.second)
val httpCacheSeconds = 1.days.inWholeSeconds val httpCacheSeconds = 1.days.inWholeSeconds
ctx.header("cache-control", "max-age=$httpCacheSeconds") ctx.header("cache-control", "max-age=$httpCacheSeconds")

View File

@@ -48,7 +48,8 @@ object Page {
suspend fun getPageImage( suspend fun getPageImage(
mangaId: Int, mangaId: Int,
chapterId: Int, chapterId: Int? = null,
chapterIndex: Int? = null,
index: Int, index: Int,
format: String? = null, format: String? = null,
progressFlow: ((StateFlow<Int>) -> Unit)? = null, progressFlow: ((StateFlow<Int>) -> Unit)? = null,
@@ -56,10 +57,17 @@ object Page {
val mangaEntry = transaction { MangaTable.selectAll().where { MangaTable.id eq mangaId }.first() } val mangaEntry = transaction { MangaTable.selectAll().where { MangaTable.id eq mangaId }.first() }
val chapterEntry = val chapterEntry =
transaction { transaction {
if (chapterId != null) {
ChapterTable ChapterTable
.selectAll() .selectAll()
.where { ChapterTable.id eq chapterId } .where { ChapterTable.id eq chapterId }
.first() .first()
} else {
ChapterTable
.selectAll()
.where { ChapterTable.manga eq mangaId and (ChapterTable.sourceOrder eq chapterIndex!!) }
.first()
}
} }
val chapterId = chapterEntry[ChapterTable.id].value val chapterId = chapterEntry[ChapterTable.id].value