mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-25 10:58:50 +01:00
Fix download stream not canceled
This commit is contained in:
parent
cf3f855cd3
commit
aa1c90282c
1 changed files with 11 additions and 6 deletions
|
@ -57,12 +57,17 @@ class FileDownloader extends itf.FileDownloader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DownloadEvent.listenDownloadComplete()
|
StreamSubscription<DownloadCompleteEvent>? subscription;
|
||||||
|
try {
|
||||||
|
subscription = DownloadEvent.listenDownloadComplete()
|
||||||
..onData(onDownloadComplete)
|
..onData(onDownloadComplete)
|
||||||
..onError((e, stackTrace) {
|
..onError((e, stackTrace) {
|
||||||
completer.completeError(e, stackTrace);
|
completer.completeError(e, stackTrace);
|
||||||
});
|
});
|
||||||
await completer.future;
|
await completer.future;
|
||||||
|
} finally {
|
||||||
|
subscription?.cancel();
|
||||||
|
}
|
||||||
return uri;
|
return uri;
|
||||||
} on PlatformException catch (e) {
|
} on PlatformException catch (e) {
|
||||||
switch (e.code) {
|
switch (e.code) {
|
||||||
|
|
Loading…
Reference in a new issue