Fix Downloaded pages with no cached pages from source (#1386)

This commit is contained in:
Mitchell Syer
2025-05-16 12:45:39 -04:00
committed by GitHub
parent ba6687355e
commit 336f985894
@@ -48,7 +48,6 @@ object Page {
progressFlow: ((StateFlow<Int>) -> Unit)? = null,
): Pair<InputStream, String> {
val mangaEntry = transaction { MangaTable.selectAll().where { MangaTable.id eq mangaId }.first() }
val source = getCatalogueSourceOrStub(mangaEntry[MangaTable.sourceReference])
val chapterEntry =
transaction {
ChapterTable
@@ -60,6 +59,14 @@ object Page {
}
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 =
transaction {
PageTable
@@ -79,7 +86,7 @@ object Page {
progressFlow?.invoke(tachiyomiPage.progress)
// we treat Local source differently
if (source.id == LocalSource.ID) {
if (mangaEntry[MangaTable.sourceReference] == LocalSource.ID) {
// is of archive format
if (LocalSource.pageCache.containsKey(chapterEntry[ChapterTable.url])) {
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")
}
val source = getCatalogueSourceOrStub(mangaEntry[MangaTable.sourceReference])
source as HttpSource
if (pageEntry[PageTable.imageUrl] == null) {
@@ -104,14 +112,6 @@ object Page {
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)
// Note: don't care about invalidating cache because OS cache is not permanent