浏览代码

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

arkon 4 年之前
父节点
当前提交
c9035b5df9
共有 1 个文件被更改,包括 10 次插入1 次删除
  1. 10 1
      app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt

+ 10 - 1
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(