From 7e0803ca160f94ddd7598a206b68330bcd93033d Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Sat, 4 Jul 2026 16:31:53 +0100 Subject: [PATCH] fix(download): cover progress setup with try/finally so cancel token can't leak The download-progress setup and notify() ran before the try whose finally clears the cancellation token, so a throw there leaked the token (blocking a later cancel for the same app). Move the setup inside the try. --- lib/providers/apps_provider_install.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/providers/apps_provider_install.dart b/lib/providers/apps_provider_install.dart index 2d49d942..730f382e 100644 --- a/lib/providers/apps_provider_install.dart +++ b/lib/providers/apps_provider_install.dart @@ -144,13 +144,13 @@ extension AppsProviderInstall on AppsProvider { }) async { final notifId = DownloadNotification(app.finalName, 0).id; final cancellationToken = registerDownloadCancellation(app.id); - if (apps[app.id] != null) { - apps[app.id]!.downloadProgress = 0; - apps[app.id]!.downloadReceivedBytes = null; - apps[app.id]!.downloadTotalBytes = null; - notify(); - } try { + if (apps[app.id] != null) { + apps[app.id]!.downloadProgress = 0; + apps[app.id]!.downloadReceivedBytes = null; + apps[app.id]!.downloadTotalBytes = null; + notify(); + } if (app.apkUrls.isEmpty) throw NoAPKError(); if (app.preferredApkIndex >= app.apkUrls.length) { app = app.copyWith(preferredApkIndex: app.apkUrls.length - 1);