mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 15:57:25 +00:00
improve download
This commit is contained in:
@@ -508,6 +508,8 @@ class _ImageDownloadWrapper {
|
|||||||
|
|
||||||
var completers = <Completer<_ImageDownloadWrapper>>[];
|
var completers = <Completer<_ImageDownloadWrapper>>[];
|
||||||
|
|
||||||
|
var retry = 3;
|
||||||
|
|
||||||
void start() async {
|
void start() async {
|
||||||
int lastBytes = 0;
|
int lastBytes = 0;
|
||||||
try {
|
try {
|
||||||
@@ -531,6 +533,11 @@ class _ImageDownloadWrapper {
|
|||||||
}
|
}
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
Log.error("Download", e.toString(), s);
|
Log.error("Download", e.toString(), s);
|
||||||
|
retry--;
|
||||||
|
if (retry > 0) {
|
||||||
|
start();
|
||||||
|
return;
|
||||||
|
}
|
||||||
error = e.toString();
|
error = e.toString();
|
||||||
for (var c in completers) {
|
for (var c in completers) {
|
||||||
if (!c.isCompleted) {
|
if (!c.isCompleted) {
|
||||||
@@ -561,6 +568,9 @@ abstract mixin class _TransferSpeedMixin {
|
|||||||
|
|
||||||
void onData(int length) {
|
void onData(int length) {
|
||||||
if (timer == null) return;
|
if (timer == null) return;
|
||||||
|
if(length < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
_bytesSinceLastSecond += length;
|
_bytesSinceLastSecond += length;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -573,6 +583,7 @@ abstract mixin class _TransferSpeedMixin {
|
|||||||
if (timer != null) {
|
if (timer != null) {
|
||||||
timer!.cancel();
|
timer!.cancel();
|
||||||
}
|
}
|
||||||
|
_bytesSinceLastSecond = 0;
|
||||||
timer = Timer.periodic(const Duration(seconds: 1), onNextSecond);
|
timer = Timer.periodic(const Duration(seconds: 1), onNextSecond);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -172,11 +172,13 @@ class _DownloadTaskTileState extends State<_DownloadTaskTile> {
|
|||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Expanded(
|
||||||
|
child: Text(
|
||||||
widget.task.title,
|
widget.task.title,
|
||||||
style: Theme.of(context).textTheme.bodyMedium,
|
style: Theme.of(context).textTheme.bodyMedium,
|
||||||
|
maxLines: 2,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const Spacer(),
|
|
||||||
MenuButton(
|
MenuButton(
|
||||||
entries: [
|
entries: [
|
||||||
MenuEntry(
|
MenuEntry(
|
||||||
|
Reference in New Issue
Block a user