From 34a40b01314fe9f7ba886724395af4f7a04b559d Mon Sep 17 00:00:00 2001 From: inorichi Date: Sat, 2 Dec 2017 17:29:05 +0100 Subject: [PATCH] Start downloader after a library update. It should help with some catalogue issues --- .../eu/kanade/tachiyomi/data/download/DownloadManager.kt | 5 +++-- .../java/eu/kanade/tachiyomi/data/download/Downloader.kt | 7 +++++-- .../kanade/tachiyomi/data/library/LibraryUpdateService.kt | 4 +++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt index de74f1e07..17efd8e95 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt @@ -85,9 +85,10 @@ class DownloadManager(context: Context) { * * @param manga the manga of the chapters. * @param chapters the list of chapters to enqueue. + * @param autoStart whether to start the downloader after enqueing the chapters. */ - fun downloadChapters(manga: Manga, chapters: List) { - downloader.queueChapters(manga, chapters) + fun downloadChapters(manga: Manga, chapters: List, autoStart: Boolean = true) { + downloader.queueChapters(manga, chapters, autoStart) } /** 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 cbcb2045c..88f32553b 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 @@ -219,8 +219,9 @@ class Downloader(private val context: Context, * * @param manga the manga of the chapters to download. * @param chapters the list of chapters to download. + * @param autoStart whether to start the downloader after enqueing the chapters. */ - fun queueChapters(manga: Manga, chapters: List) = launchUI { + fun queueChapters(manga: Manga, chapters: List, autoStart: Boolean) = launchUI { val source = sourceManager.get(manga.source) as? HttpSource ?: return@launchUI // Called in background thread, the operation can be slow with SAF. @@ -261,7 +262,9 @@ class Downloader(private val context: Context, } // Start downloader if needed - DownloadService.start(this@Downloader.context) + if (autoStart) { + DownloadService.start(this@Downloader.context) + } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt index 50a19ef4d..880764854 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt @@ -333,7 +333,9 @@ class LibraryUpdateService( val dbChapters = chapters.map { mangaChapters.find { mangaChapter -> mangaChapter.url == it.url }!! } - downloadManager.downloadChapters(manga, dbChapters) + // We don't want to start downloading while the library is updating, because websites + // may don't like it and they could ban the user. + downloadManager.downloadChapters(manga, dbChapters, false) } /**