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.
This commit is contained in:
Imran Remtulla
2026-07-04 16:31:53 +01:00
parent aa9431e53c
commit 7e0803ca16

View File

@@ -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);