Fixup HttpPageLoader _loadPage (#8984)

Fixup for e4bc8990 (#8955)

HttpSource.fetchImage() uses Call.asObservableSuccess(), which
cancels the call on unsubscribe. This causes the call to be cancelled
before it is used, leading to a "java.net.SocketException: Socket is
closed" when trying to use the response in putImageToCache().

To fix this, use Call.awaitSuccess() via a new HttpSource.getImage()
suspending function. This addition to source-api is only intended for
app use, so it will not be added to the extensions-api stubs.

(cherry picked from commit b4b3a4d2869fae7839b4b3111e289056e33cfea8)

# Conflicts:
#	app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/HttpPageLoader.kt
This commit is contained in:
Two-Ai
2023-01-25 18:18:12 -05:00
committed by Jobobby04
parent a0497d079d
commit acc3e16230
3 changed files with 24 additions and 2 deletions
@@ -13,7 +13,7 @@ import eu.kanade.tachiyomi.util.lang.launchIO
import eu.kanade.tachiyomi.util.lang.withIOContext
import exh.source.isEhBasedSource
import exh.util.DataSaver
import exh.util.DataSaver.Companion.fetchImage
import exh.util.DataSaver.Companion.getImage
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@@ -241,7 +241,7 @@ class HttpPageLoader(
if (!chapterCache.isImageInCache(imageUrl)) {
page.status = Page.State.DOWNLOAD_IMAGE
val imageResponse = source.fetchImage(page, dataSaver).awaitSingle()
val imageResponse = source.getImage(page, dataSaver)
chapterCache.putImageToCache(imageUrl, imageResponse)
}