mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-04 03:14:40 -05:00
Fix Downloaded pages with no cached pages from source (#1386)
This commit is contained in:
@@ -48,7 +48,6 @@ object Page {
|
|||||||
progressFlow: ((StateFlow<Int>) -> Unit)? = null,
|
progressFlow: ((StateFlow<Int>) -> Unit)? = null,
|
||||||
): Pair<InputStream, String> {
|
): Pair<InputStream, String> {
|
||||||
val mangaEntry = transaction { MangaTable.selectAll().where { MangaTable.id eq mangaId }.first() }
|
val mangaEntry = transaction { MangaTable.selectAll().where { MangaTable.id eq mangaId }.first() }
|
||||||
val source = getCatalogueSourceOrStub(mangaEntry[MangaTable.sourceReference])
|
|
||||||
val chapterEntry =
|
val chapterEntry =
|
||||||
transaction {
|
transaction {
|
||||||
ChapterTable
|
ChapterTable
|
||||||
@@ -60,6 +59,14 @@ object Page {
|
|||||||
}
|
}
|
||||||
val chapterId = chapterEntry[ChapterTable.id].value
|
val chapterId = chapterEntry[ChapterTable.id].value
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (chapterEntry[ChapterTable.isDownloaded]) {
|
||||||
|
return ChapterDownloadHelper.getImage(mangaId, chapterId, index)
|
||||||
|
}
|
||||||
|
} catch (_: Exception) {
|
||||||
|
// ignore and fetch again
|
||||||
|
}
|
||||||
|
|
||||||
val pageEntry =
|
val pageEntry =
|
||||||
transaction {
|
transaction {
|
||||||
PageTable
|
PageTable
|
||||||
@@ -79,7 +86,7 @@ object Page {
|
|||||||
progressFlow?.invoke(tachiyomiPage.progress)
|
progressFlow?.invoke(tachiyomiPage.progress)
|
||||||
|
|
||||||
// we treat Local source differently
|
// we treat Local source differently
|
||||||
if (source.id == LocalSource.ID) {
|
if (mangaEntry[MangaTable.sourceReference] == LocalSource.ID) {
|
||||||
// is of archive format
|
// is of archive format
|
||||||
if (LocalSource.pageCache.containsKey(chapterEntry[ChapterTable.url])) {
|
if (LocalSource.pageCache.containsKey(chapterEntry[ChapterTable.url])) {
|
||||||
val pageStream = LocalSource.pageCache[chapterEntry[ChapterTable.url]]!![index]
|
val pageStream = LocalSource.pageCache[chapterEntry[ChapterTable.url]]!![index]
|
||||||
@@ -91,6 +98,7 @@ object Page {
|
|||||||
return imageFile.inputStream() to (ImageUtil.findImageType { imageFile.inputStream() }?.mime ?: "image/jpeg")
|
return imageFile.inputStream() to (ImageUtil.findImageType { imageFile.inputStream() }?.mime ?: "image/jpeg")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val source = getCatalogueSourceOrStub(mangaEntry[MangaTable.sourceReference])
|
||||||
source as HttpSource
|
source as HttpSource
|
||||||
|
|
||||||
if (pageEntry[PageTable.imageUrl] == null) {
|
if (pageEntry[PageTable.imageUrl] == null) {
|
||||||
@@ -104,14 +112,6 @@ object Page {
|
|||||||
|
|
||||||
val fileName = getPageName(index)
|
val fileName = getPageName(index)
|
||||||
|
|
||||||
try {
|
|
||||||
if (chapterEntry[ChapterTable.isDownloaded]) {
|
|
||||||
return ChapterDownloadHelper.getImage(mangaId, chapterId, index)
|
|
||||||
}
|
|
||||||
} catch (_: Exception) {
|
|
||||||
// ignore and fetch again
|
|
||||||
}
|
|
||||||
|
|
||||||
val cacheSaveDir = getChapterCachePath(mangaId, chapterId)
|
val cacheSaveDir = getChapterCachePath(mangaId, chapterId)
|
||||||
|
|
||||||
// Note: don't care about invalidating cache because OS cache is not permanent
|
// Note: don't care about invalidating cache because OS cache is not permanent
|
||||||
|
|||||||
Reference in New Issue
Block a user