2022-01-18 21:26:52 +00:00
|
|
|
class FileDownloadProgress {
|
|
|
|
int chunksDownloaded = 0;
|
|
|
|
int chunksTotal = 1;
|
|
|
|
bool complete = false;
|
|
|
|
bool gotManifest = false;
|
|
|
|
bool interrupted = false;
|
|
|
|
String? downloadedTo;
|
|
|
|
DateTime? timeStart;
|
|
|
|
DateTime? timeEnd;
|
2022-07-06 19:14:40 +00:00
|
|
|
DateTime? requested;
|
2023-04-20 22:48:00 +00:00
|
|
|
DateTime lastUpdate = DateTime.now();
|
2022-01-18 21:26:52 +00:00
|
|
|
|
|
|
|
FileDownloadProgress(this.chunksTotal, this.timeStart);
|
2022-07-06 19:14:40 +00:00
|
|
|
|
2022-01-18 21:26:52 +00:00
|
|
|
double progress() {
|
|
|
|
return 1.0 * chunksDownloaded / chunksTotal;
|
|
|
|
}
|
2023-04-20 22:48:00 +00:00
|
|
|
|
|
|
|
void markUpdate() {
|
|
|
|
lastUpdate = DateTime.now();
|
|
|
|
}
|
2022-01-18 21:26:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
String prettyBytes(int bytes) {
|
|
|
|
if (bytes > 1000000000) {
|
|
|
|
return (1.0 * bytes / 1000000000).toStringAsFixed(1) + " GB";
|
|
|
|
} else if (bytes > 1000000) {
|
|
|
|
return (1.0 * bytes / 1000000).toStringAsFixed(1) + " MB";
|
|
|
|
} else if (bytes > 1000) {
|
|
|
|
return (1.0 * bytes / 1000).toStringAsFixed(1) + " kB";
|
|
|
|
} else {
|
|
|
|
return bytes.toString() + " B";
|
|
|
|
}
|
2022-01-19 21:58:52 +00:00
|
|
|
}
|