Download from up to 5 different sources concurrently (closes #2534)

(cherry picked from commit c9035b5df9a331dbed3322eb6ad95bc81d1d7f22)
This commit is contained in:
arkon 2020-05-08 18:41:27 -04:00 committed by Jobobby04
parent 3ffb80c6f1
commit ce0d99b78f

View File

@ -181,7 +181,16 @@ class Downloader(
subscriptions.clear()
subscriptions += downloadsRelay.concatMapIterable { it }
.concatMap { downloadChapter(it).subscribeOn(Schedulers.io()) }
// Concurrently download from 5 different sources
.groupBy { it.source }
.flatMap(
{ bySource ->
bySource.concatMap { download ->
downloadChapter(download).subscribeOn(Schedulers.io())
}
},
5
)
.onBackpressureBuffer()
.observeOn(AndroidSchedulers.mainThread())
.subscribe(