From 5385642a5b1577cc4f90b822f70f5892091c054c Mon Sep 17 00:00:00 2001 From: len Date: Thu, 21 Apr 2016 15:57:47 +0200 Subject: [PATCH] Downloads now retry requests after some seconds. Closes #271 --- .../eu/kanade/tachiyomi/data/download/DownloadManager.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt index c94712a24c..41a930c88a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt @@ -26,6 +26,7 @@ import timber.log.Timber import java.io.File import java.io.FileReader import java.util.* +import java.util.concurrent.TimeUnit class DownloadManager(private val context: Context, private val sourceManager: SourceManager, private val preferences: PreferencesHelper) { @@ -238,7 +239,10 @@ class DownloadManager(private val context: Context, private val sourceManager: S } Observable.just(page) } - .retry(2) + .retryWhen { + it.zipWith(Observable.range(1, 3)) { errors, retries -> retries } + .flatMap { retries -> Observable.timer((retries * 2).toLong(), TimeUnit.SECONDS) } + } } // Public method to get the image from the filesystem. It does NOT provide any way to download the image