Explorar el Código

Fix stucked downloads when service not started (#7846)

* Fix stucked downloads when service not started

* Fix chapter download restart even if should be deleted
nzoba hace 2 años
padre
commit
a70b848646

+ 2 - 2
app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt

@@ -163,12 +163,12 @@ class DownloadManager(
      * @param downloads the list of downloads to enqueue.
      */
     fun addDownloadsToStartOfQueue(downloads: List<Download>) {
-        val wasEmpty = queue.isEmpty()
+        if (downloads.isEmpty()) return
         queue.toMutableList().apply {
             addAll(0, downloads)
             reorderQueue(this)
         }
-        if (wasEmpty) startDownloads()
+        if (!DownloadService.isRunning(context)) DownloadService.start(context)
     }
 
     /**

+ 2 - 0
app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt

@@ -500,6 +500,8 @@ class ReaderPresenter(
 
         if (removeAfterReadSlots != 0 && chapterDownload != null) {
             downloadManager.addDownloadsToStartOfQueue(listOf(chapterDownload!!))
+        } else {
+            chapterDownload = null
         }
         // Check if deleting option is enabled and chapter exists
         if (removeAfterReadSlots != -1 && chapterToDelete != null) {