mirror of
https://github.com/ImranR98/Obtainium.git
synced 2026-08-02 02:17:21 -04:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user