Skip bookmark check when cancelling downloads (#5853)

* Skip bookmark check when cancelling downloads

* DownloadManager: simplified filteredChapters declaration

* Completed documentation of DownloadManager's deleteChapters()

(cherry picked from commit 02b430a5bf3bdf7db6c9e04fd3f954cce4558d12)
This commit is contained in:
Aran Leite 2021-09-04 23:43:56 -03:00 committed by Jobobby04
parent 6eac0f6f98
commit 0f0937adf5

View File

@ -218,7 +218,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) {
@ -226,7 +226,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)
}
}
@ -236,9 +236,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<Chapter>, manga: Manga, source: Source): List<Chapter> {
val filteredChapters = getChaptersToDelete(chapters)
fun deleteChapters(chapters: List<Chapter>, manga: Manga, source: Source, isCancelling: Boolean = false): List<Chapter> {
val filteredChapters = if (isCancelling) {
chapters
} else {
getChaptersToDelete(chapters)
}
launchIO {
removeFromDownloadQueue(filteredChapters)