From 3bdca95d964f79f04d673c9a939acfe27ebed3df Mon Sep 17 00:00:00 2001 From: inorichi Date: Wed, 4 Nov 2015 19:54:01 +0100 Subject: [PATCH] Use flatMap with a limit instead of windows for concurrent downloads --- .../eu/kanade/mangafeed/data/helpers/DownloadManager.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/kanade/mangafeed/data/helpers/DownloadManager.java b/app/src/main/java/eu/kanade/mangafeed/data/helpers/DownloadManager.java index 9b6c62ad12..bb0e2d33d0 100644 --- a/app/src/main/java/eu/kanade/mangafeed/data/helpers/DownloadManager.java +++ b/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)); }