From f28b2d887e794c4d73442f988933d92dedfba3bd Mon Sep 17 00:00:00 2001 From: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Date: Sat, 10 Oct 2026 12:44:45 +0600 Subject: [PATCH] Cancel queued downloads of chapters the source removed (#3845) Closes #3845 Fixes #3811 Fixes #3501 Co-authored-by: Joseph <50675784+JoJoKorok@users.noreply.github.com> --- .../domain/chapter/interactor/SyncChaptersWithSource.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/main/java/eu/kanade/domain/chapter/interactor/SyncChaptersWithSource.kt b/app/src/main/java/eu/kanade/domain/chapter/interactor/SyncChaptersWithSource.kt index cd5486bd5..85dc9c352 100644 --- a/app/src/main/java/eu/kanade/domain/chapter/interactor/SyncChaptersWithSource.kt +++ b/app/src/main/java/eu/kanade/domain/chapter/interactor/SyncChaptersWithSource.kt @@ -142,6 +142,11 @@ class SyncChaptersWithSource( val removedChapters = dbChapters.filterNot { it.url in sourceUrls } + // The source no longer lists these, so their queued downloads could only fail + removedChapters.mapNotNull { downloadManager.getQueuedDownloadOrNull(it.id) } + .takeIf { it.isNotEmpty() } + ?.let(downloadManager::cancelQueuedDownloads) + // Return if there's nothing to add, delete, or update to avoid unnecessary db transactions. if (newChapters.isEmpty() && removedChapters.isEmpty() && updatedChapters.isEmpty()) { if (manualFetch || manga.fetchInterval == 0 || manga.nextUpdate < fetchWindow.first) {