Skip bookmark check when cancelling downloads (#5853)

* Skip bookmark check when cancelling downloads

* DownloadManager: simplified filteredChapters declaration

* Completed documentation of DownloadManager's deleteChapters()
This commit is contained in:
Aran Leite 2021-09-04 23:43:56 -03:00 committed by GitHub
parent 7878053df2
commit 02b430a5bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -217,7 +217,7 @@ class DownloadManager(private val context: Context) {
* @param download the download to cancel. * @param download the download to cancel.
*/ */
fun deletePendingDownload(download: Download) { 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) { fun deletePendingDownloads(vararg downloads: Download) {
@ -225,7 +225,7 @@ class DownloadManager(private val context: Context) {
downloadsByManga.map { entry -> downloadsByManga.map { entry ->
val manga = entry.value.first().manga val manga = entry.value.first().manga
val source = entry.value.first().source 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 chapters the list of chapters to delete.
* @param manga the manga of the chapters. * @param manga the manga of the chapters.
* @param source the source 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> { fun deleteChapters(chapters: List<Chapter>, manga: Manga, source: Source, isCancelling: Boolean = false): List<Chapter> {
val filteredChapters = getChaptersToDelete(chapters) val filteredChapters = if (isCancelling) {
chapters
} else {
getChaptersToDelete(chapters)
}
launchIO { launchIO {
removeFromDownloadQueue(filteredChapters) removeFromDownloadQueue(filteredChapters)