mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-25 02:48:54 +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()
|
||||
..onData(onDownloadComplete)
|
||||
..onError((e, stackTrace) {
|
||||
completer.completeError(e, stackTrace);
|
||||
});
|
||||
await completer.future;
|
||||
StreamSubscription<DownloadCompleteEvent>? subscription;
|
||||
try {
|
||||
subscription = DownloadEvent.listenDownloadComplete()
|
||||
..onData(onDownloadComplete)
|
||||
..onError((e, stackTrace) {
|
||||
completer.completeError(e, stackTrace);
|
||||
});
|
||||
await completer.future;
|
||||
} finally {
|
||||
subscription?.cancel();
|
||||
}
|
||||
return uri;
|
||||
} on PlatformException catch (e) {
|
||||
switch (e.code) {
|
||||
|
|
Loading…
Reference in a new issue