瀏覽代碼

Start downloader after a library update. It should help with some catalogue issues

inorichi 7 年之前
父節點
當前提交
34a40b0131

+ 3 - 2
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<Chapter>) {
-        downloader.queueChapters(manga, chapters)
+    fun downloadChapters(manga: Manga, chapters: List<Chapter>, autoStart: Boolean = true) {
+        downloader.queueChapters(manga, chapters, autoStart)
     }
 
     /**

+ 5 - 2
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<Chapter>) = launchUI {
+    fun queueChapters(manga: Manga, chapters: List<Chapter>, 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)
+            }
         }
     }
 

+ 3 - 1
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)
     }
 
     /**