mirror of
https://github.com/Suwayomi/Tachidesk.git
synced 2025-12-24 05:22:38 +01:00
Fix pages after refactoring downloads (#1639)
This commit is contained in:
@@ -466,21 +466,27 @@ 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(
|
||||||
ctx.header("content-type", it.second)
|
mangaId = mangaId,
|
||||||
val httpCacheSeconds = 1.days.inWholeSeconds
|
chapterIndex = chapterIndex,
|
||||||
ctx.header("cache-control", "max-age=$httpCacheSeconds")
|
index = index,
|
||||||
ctx.result(it.first)
|
format = format,
|
||||||
|
)
|
||||||
|
}.thenApply {
|
||||||
|
ctx.header("content-type", it.second)
|
||||||
|
val httpCacheSeconds = 1.days.inWholeSeconds
|
||||||
|
ctx.header("cache-control", "max-age=$httpCacheSeconds")
|
||||||
|
ctx.result(it.first)
|
||||||
|
|
||||||
if (updateProgress == true) {
|
if (updateProgress == true) {
|
||||||
val chapterId = Chapter.updateChapterProgress(mangaId, chapterIndex, pageNo = index)
|
val chapterId = Chapter.updateChapterProgress(mangaId, chapterIndex, pageNo = index)
|
||||||
// Sync progress with KoreaderSync if chapter update was successful
|
// Sync progress with KoreaderSync if chapter update was successful
|
||||||
if (chapterId != -1) {
|
if (chapterId != -1) {
|
||||||
GlobalScope.launch { KoreaderSyncService.pushProgress(chapterId) }
|
GlobalScope.launch { KoreaderSyncService.pushProgress(chapterId) }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
withResults = {
|
withResults = {
|
||||||
|
|||||||
@@ -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 {
|
||||||
ChapterTable
|
if (chapterId != null) {
|
||||||
.selectAll()
|
ChapterTable
|
||||||
.where { ChapterTable.id eq chapterId }
|
.selectAll()
|
||||||
.first()
|
.where { ChapterTable.id eq chapterId }
|
||||||
|
.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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user