From c9035b5df9a331dbed3322eb6ad95bc81d1d7f22 Mon Sep 17 00:00:00 2001 From: arkon Date: Fri, 8 May 2020 18:41:27 -0400 Subject: [PATCH] Download from up to 5 different sources concurrently (closes #2534) --- .../eu/kanade/tachiyomi/data/download/Downloader.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt index c6bc9a65a..ae47453eb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt @@ -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(