浏览代码

Use flatMap with a limit instead of windows for concurrent downloads

inorichi 9 年之前
父节点
当前提交
3bdca95d96
共有 1 个文件被更改,包括 2 次插入4 次删除
  1. 2 4
      app/src/main/java/eu/kanade/mangafeed/data/helpers/DownloadManager.java

+ 2 - 4
app/src/main/java/eu/kanade/mangafeed/data/helpers/DownloadManager.java

@@ -68,9 +68,7 @@ public class DownloadManager {
                 .subscribeOn(Schedulers.io())
                 .filter(event -> !isChapterDownloaded(event))
                 .flatMap(this::createDownload)
-                .window(preferences.getDownloadThreads())
-                .concatMap(concurrentDownloads -> concurrentDownloads
-                        .concatMap(this::downloadChapter))
+                .flatMap(this::downloadChapter, preferences.getDownloadThreads())
                 .onBackpressureBuffer()
                 .subscribe();
     }
@@ -131,7 +129,7 @@ public class DownloadManager {
                         download.source.getRemainingImageUrlsFromPageList(pageList)))
                 // Start downloading images, consider we can have downloaded images already
                 .concatMap(page -> getDownloadedImage(page, download.source, download.directory))
-                // Remove from the queue
+                // Do after download completes
                 .doOnCompleted(() -> onChapterDownloaded(download));
     }