Skip to content

Commit 6414800

Browse files
fixed undefined totale length of the file
1 parent d32ebee commit 6414800

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

bin/downloader.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,23 @@ Future<String> download(String url) async {
5858
final response = await dio.download(
5959
url,
6060
savePath,
61+
options: Options(
62+
headers: {HttpHeaders.acceptEncodingHeader: '*'}, // Disable gzip
63+
),
6164
onReceiveProgress: (received, total) {
62-
final progress = (received / total * 100).toInt();
65+
if (total <= -1) return;
66+
67+
final progress = ((received / total) * 100).toInt();
6368
showProgress(progress);
6469
},
6570
);
6671

6772
final contentType =
6873
(response.headers.map['content-type'] as List)[0] as String;
6974

70-
final extion = contentType.split('/').last;
75+
final fileExtension = contentType.split('/').last;
7176

72-
final newSavePath = renameIfNoExtenion(savePath, extion);
77+
final newSavePath = renameIfNoExtenion(savePath, fileExtension);
7378

7479
if (newSavePath != null) return newSavePath;
7580

0 commit comments

Comments
 (0)