Skip to content

Fix: cancel download not working#196

Open
mduccc wants to merge 1 commit intoDenisovAV:mainfrom
mduccc:fix/cancel-download
Open

Fix: cancel download not working#196
mduccc wants to merge 1 commit intoDenisovAV:mainfrom
mduccc:fix/cancel-download

Conversation

@mduccc
Copy link

@mduccc mduccc commented Mar 16, 2026

Problem

Cancelling a download via CancelToken had no effect — the download continued running even after cancellation was requested.

Root Cause

In SmartDownloader.downloadWithProgress(), the .then() callback was not async and _downloadWithSmartRetry() was not awaited:

// Before (broken)
_ensureConfigured(foreground).then((_) {
  _downloadWithSmartRetry(...);  // unawaited!
}).whenComplete(() {
  cancellationListener?.cancel();  // fires immediately!
});

…llback

The whenComplete cleanup was firing immediately because _downloadWithSmartRetry
was not awaited inside the then() callback, causing the cancellation listener
to be disposed before the download completed.
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.

2 participants