Revert "Request a new image from E-Hentai if it fails to download, should make E-Hentai downloads more relaible"

This reverts commit a21d7f4f905cdf8ad64ac1ff6efaf6fc80efb452.
This commit is contained in:
Jobobby04 2021-01-08 16:24:42 -05:00
parent fca7dad7b0
commit 4afe227e02

View File

@ -23,7 +23,6 @@ import eu.kanade.tachiyomi.util.lang.plusAssign
import eu.kanade.tachiyomi.util.storage.DiskUtil
import eu.kanade.tachiyomi.util.storage.saveTo
import eu.kanade.tachiyomi.util.system.ImageUtil
import exh.isEhBasedSource
import kotlinx.coroutines.async
import okhttp3.Response
import rx.Observable
@ -390,19 +389,7 @@ class Downloader(
private fun downloadImage(page: Page, source: HttpSource, tmpDir: UniFile, filename: String): Observable<UniFile> {
page.status = Page.DOWNLOAD_IMAGE
page.progress = 0
return /* SY --> If the source is E-Hentai request a new page if null */ Observable.just(Unit)
.flatMap {
if (page.imageUrl == null && source.isEhBasedSource()) {
source.fetchImageUrl(page)
} else Observable.just(null)
}
.doOnNext { imageUrl ->
if (imageUrl != null) page.imageUrl = imageUrl
}
.flatMap {
source.fetchImage(page)
}
// SY <--
return source.fetchImage(page)
.map { response ->
val file = tmpDir.createFile("$filename.tmp")
try {
@ -412,9 +399,6 @@ class Downloader(
} catch (e: Exception) {
response.close()
file.delete()
// SY --> E-Hentai sometimes has dead pages, so we request a new one if it fails
if (source.isEhBasedSource()) page.imageUrl = null
// SY <--
throw e
}
file