@@ -514,23 +514,38 @@ Future<bool> downloadDependency(InjectableDll dll, String outputPath) async {
514
514
}
515
515
}
516
516
517
- Future <void > downloadRebootDll (File file, String url, bool aboveS20) async {
517
+ Future <bool > downloadRebootDll (File file, String url, bool aboveS20) async {
518
518
Directory ? outputDir;
519
519
try {
520
520
var response = await http.get (Uri .parse (url));
521
521
if (response.statusCode != 200 ) {
522
522
response = await http.get (Uri .parse (aboveS20 ? _kRebootAboveS20FallbackDownloadUrl : _kRebootBelowS20FallbackDownloadUrl));
523
523
if (response.statusCode != 200 ) {
524
- throw Exception ( "status code ${response .statusCode }" ) ;
524
+ throw "status code ${response .statusCode }" ;
525
525
}
526
526
}
527
527
528
528
outputDir = await installationDirectory.createTemp ("reboot_out" );
529
529
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
+ }
534
549
} finally {
535
550
if (outputDir != null ) {
536
551
delete (outputDir);
0 commit comments