From 02b430a5bf3bdf7db6c9e04fd3f954cce4558d12 Mon Sep 17 00:00:00 2001 From: Aran Leite Date: Sat, 4 Sep 2021 23:43:56 -0300 Subject: [PATCH] Skip bookmark check when cancelling downloads (#5853) * Skip bookmark check when cancelling downloads * DownloadManager: simplified filteredChapters declaration * Completed documentation of DownloadManager's deleteChapters() --- .../tachiyomi/data/download/DownloadManager.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 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 8e1f148eb1..574221e680 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 @@ -217,7 +217,7 @@ class DownloadManager(private val context: Context) { * @param download the download to cancel. */ fun deletePendingDownload(download: Download) { - deleteChapters(listOf(download.chapter), download.manga, download.source) + deleteChapters(listOf(download.chapter), download.manga, download.source, true) } fun deletePendingDownloads(vararg downloads: Download) { @@ -225,7 +225,7 @@ class DownloadManager(private val context: Context) { downloadsByManga.map { entry -> val manga = entry.value.first().manga val source = entry.value.first().source - deleteChapters(entry.value.map { it.chapter }, manga, source) + deleteChapters(entry.value.map { it.chapter }, manga, source, true) } } @@ -235,9 +235,15 @@ class DownloadManager(private val context: Context) { * @param chapters the list of chapters to delete. * @param manga the manga of the chapters. * @param source the source of the chapters. + * @param isCancelling true if it's simply cancelling a download */ - fun deleteChapters(chapters: List, manga: Manga, source: Source): List { - val filteredChapters = getChaptersToDelete(chapters) + fun deleteChapters(chapters: List, manga: Manga, source: Source, isCancelling: Boolean = false): List { + val filteredChapters = if (isCancelling) { + chapters + } else { + getChaptersToDelete(chapters) + } + launchIO { removeFromDownloadQueue(filteredChapters)