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 30183a55c..6f4a368b9 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 @@ -67,7 +67,7 @@ class DownloadManager( */ fun pauseDownloads() { downloader.pause() - DownloadService.stop(context) + downloader.stop() } /** @@ -75,7 +75,7 @@ class DownloadManager( */ fun clearQueue() { downloader.clearQueue() - DownloadService.stop(context) + downloader.stop() } /** @@ -115,8 +115,8 @@ class DownloadManager( val wasRunning = downloader.isRunning if (downloads.isEmpty()) { - DownloadService.stop(context) - queue.clear() + downloader.clearQueue() + downloader.stop() return } @@ -275,7 +275,6 @@ class DownloadManager( if (wasRunning) { if (queue.isEmpty()) { - DownloadService.stop(context) downloader.stop() } else if (queue.isNotEmpty()) { downloader.start() 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 d41a51eba..061927054 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 @@ -167,6 +167,11 @@ class Downloader( } isPaused = false + + // Prevent recursion when DownloadService.onDestroy() calls downloader.stop() + if (DownloadService.isRunning.value) { + DownloadService.stop(context) + } } /** @@ -217,9 +222,9 @@ class Downloader( completeDownload(it) }, { error -> - DownloadService.stop(context) logcat(LogPriority.ERROR, error) notifier.onError(error.message) + stop() }, ) } @@ -634,7 +639,7 @@ class Downloader( queue.remove(download) } if (areAllDownloadsFinished()) { - DownloadService.stop(context) + stop() } }