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 8343c8b895..99614eb02d 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 @@ -197,14 +197,28 @@ class Downloader( subscriptions.clear() subscriptions += downloadsRelay.concatMapIterable { it } - .concatMap { downloadChapter(it).subscribeOn(Schedulers.io()) }.onBackpressureBuffer() - .observeOn(AndroidSchedulers.mainThread()).subscribe({ - completeDownload(it) - }, { error -> - DownloadService.stop(context) - Timber.e(error) - notifier.onError(error.message) - }) + // 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( + { + completeDownload(it) + }, + { error -> + DownloadService.stop(context) + Timber.e(error) + notifier.onError(error.message) + } + ) } /**