Skip to content

manager: avoid enqueuing paused downloads again - #1637

Open
fhgffy wants to merge 1 commit into
bmax121:mainfrom
fhgffy:fix/paused-download-deduplication
Open

fhgffy wants to merge 1 commit into
bmax121:mainfrom
fhgffy:fix/paused-download-deduplication

Conversation

@fhgffy

@fhgffy fhgffy commented Oct 6, 2026

Copy link
Copy Markdown

download() queries RUNNING, PAUSED and PENDING downloads, but its matching-row check only returns early for RUNNING/PENDING. A paused download therefore falls through to enqueue() when the user requests the same URL or filename again.

Include PAUSED in the existing onDownloading()/early-return branch. Android defines this status as waiting to retry or resume, so the existing job is still active: https://developer.android.com/reference/android/app/DownloadManager#STATUS_PAUSED

Reproduction and checks:

  • Compiled the entire production Downloader.kt and LatestVersionInfo.kt with Kotlin 2.4.10 and Java 21 in an external host-JVM harness
  • A matching paused row produces an extra enqueue on the base; the patch produces no enqueue and calls onDownloading() once
  • The focused suite goes from 10/15 to 15/15 passing, covering URL/title matches, all three active statuses, unrelated rows, null/empty history, request fields, callback exceptions and cursor closure
  • A separate review repeated the suite with newly enqueued jobs exposed as PENDING. The base creates one extra request before later calls find it; the patch creates none. Real repeated-request counts depend on provider state and timing
  • git diff --check passes

Android/Compose boundaries are test doubles. This external harness is not a committed Android test target and does not test the actual DownloadProvider, network resumption or concurrency. Full Gradle/Android build, lint, emulator/device and UI interruption checks have not been run. Existing URL-or-title matching and completed-download behavior are unchanged.

@fhgffy
fhgffy marked this pull request as ready for review October 6, 2026 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant