mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-21 08:38:37 +00:00
opt update down progress
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -13,6 +13,7 @@ class DownloadManager {
|
|||||||
final void Function([Object? error]) onDone;
|
final void Function([Object? error]) onDone;
|
||||||
|
|
||||||
DownloadStatus _status = DownloadStatus.downloading;
|
DownloadStatus _status = DownloadStatus.downloading;
|
||||||
|
|
||||||
DownloadStatus get status => _status;
|
DownloadStatus get status => _status;
|
||||||
final _cancelToken = CancelToken();
|
final _cancelToken = CancelToken();
|
||||||
late Future<void> task;
|
late Future<void> task;
|
||||||
@@ -78,11 +79,16 @@ class DownloadManager {
|
|||||||
onReceiveProgress?.call(0, contentLength);
|
onReceiveProgress?.call(0, contentLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int? last;
|
||||||
try {
|
try {
|
||||||
await for (final chunk in data.stream) {
|
await for (final chunk in data.stream) {
|
||||||
sink.add(chunk);
|
sink.add(chunk);
|
||||||
received += chunk.length;
|
received += chunk.length;
|
||||||
onReceiveProgress?.call(received, contentLength);
|
final now = DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
||||||
|
if (last != now) {
|
||||||
|
last = now;
|
||||||
|
onReceiveProgress?.call(received, contentLength);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
await sink.close();
|
await sink.close();
|
||||||
_status = DownloadStatus.completed;
|
_status = DownloadStatus.completed;
|
||||||
|
|||||||
Reference in New Issue
Block a user