Skip to content

Commit dc2d4c4

Browse files
committed
10.0.8
1 parent 5d8f6bf commit dc2d4c4

File tree

2 files changed

+34
-8
lines changed

2 files changed

+34
-8
lines changed

common/lib/src/util/downloader.dart

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -514,23 +514,38 @@ Future<bool> downloadDependency(InjectableDll dll, String outputPath) async {
514514
}
515515
}
516516

517-
Future<void> downloadRebootDll(File file, String url, bool aboveS20) async {
517+
Future<bool> downloadRebootDll(File file, String url, bool aboveS20) async {
518518
Directory? outputDir;
519519
try {
520520
var response = await http.get(Uri.parse(url));
521521
if(response.statusCode != 200) {
522522
response = await http.get(Uri.parse(aboveS20 ? _kRebootAboveS20FallbackDownloadUrl : _kRebootBelowS20FallbackDownloadUrl));
523523
if(response.statusCode != 200) {
524-
throw Exception("status code ${response.statusCode}");
524+
throw "status code ${response.statusCode}";
525525
}
526526
}
527527

528528
outputDir = await installationDirectory.createTemp("reboot_out");
529529
final tempZip = File("${outputDir.path}\\reboot.zip");
530-
await tempZip.writeAsBytes(response.bodyBytes, flush: true);
531-
await extractFileToDisk(tempZip.path, outputDir.path);
532-
final rebootDll = File(outputDir.listSync().firstWhere((element) => path.extension(element.path) == ".dll").path);
533-
await file.writeAsBytes(await rebootDll.readAsBytes(), flush: true);
530+
531+
try {
532+
await tempZip.writeAsBytes(response.bodyBytes, flush: true); // Write reboot.zip to disk
533+
534+
await tempZip.readAsBytes(); // Check implicitly if antivirus doesn't like reboot
535+
536+
await extractFileToDisk(tempZip.path, outputDir.path);
537+
538+
final rebootDll = outputDir.listSync()
539+
.firstWhere((element) => path.extension(element.path) == ".dll") as File;
540+
final rebootDllSource = await rebootDll.readAsBytes();
541+
await file.writeAsBytes(rebootDllSource, flush: true);
542+
543+
await file.readAsBytes(); // Check implicitly if antivirus doesn't like reboot
544+
545+
return true;
546+
} catch(_) {
547+
return false; // Anti virus probably flagged reboot
548+
}
534549
} finally{
535550
if(outputDir != null) {
536551
delete(outputDir);

gui/lib/src/controller/dll_controller.dart

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,25 @@ class DllController extends GetxController {
105105
duration: null
106106
);
107107
}
108-
await Future.wait(
108+
final result = await Future.wait(
109109
[
110110
downloadRebootDll(rebootBeforeS20DllFile, beforeS20Mirror.text, false),
111111
downloadRebootDll(rebootAboveS20DllFile, aboveS20Mirror.text, true),
112112
Future.delayed(const Duration(seconds: 1))
113+
.then((_) => true)
113114
],
114115
eagerError: false
115-
);
116+
).then((values) => values.reduce((first, second) => first && second));
117+
if(!result) {
118+
status.value = UpdateStatus.error;
119+
showRebootInfoBar(
120+
translations.downloadDllAntivirus(antiVirusName ?? defaultAntiVirusName, "reboot"),
121+
duration: infoBarLongDuration,
122+
severity: InfoBarSeverity.error
123+
);
124+
infoBarEntry?.close();
125+
return false;
126+
}
116127
timestamp.value = DateTime.now().millisecondsSinceEpoch;
117128
status.value = UpdateStatus.success;
118129
infoBarEntry?.close();

0 commit comments

Comments
 (0)