From dc2d4c4377117528740f4a01488b6c67dc87c00e Mon Sep 17 00:00:00 2001 From: Alessandro Autiero Date: Sun, 23 Mar 2025 23:17:20 +0100 Subject: [PATCH] 10.0.8 --- common/lib/src/util/downloader.dart | 27 +++++++++++++++++----- gui/lib/src/controller/dll_controller.dart | 15 ++++++++++-- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/common/lib/src/util/downloader.dart b/common/lib/src/util/downloader.dart index 5e771ff..5372981 100644 --- a/common/lib/src/util/downloader.dart +++ b/common/lib/src/util/downloader.dart @@ -514,23 +514,38 @@ Future downloadDependency(InjectableDll dll, String outputPath) async { } } -Future downloadRebootDll(File file, String url, bool aboveS20) async { +Future downloadRebootDll(File file, String url, bool aboveS20) async { Directory? outputDir; try { var response = await http.get(Uri.parse(url)); if(response.statusCode != 200) { response = await http.get(Uri.parse(aboveS20 ? _kRebootAboveS20FallbackDownloadUrl : _kRebootBelowS20FallbackDownloadUrl)); if(response.statusCode != 200) { - throw Exception("status code ${response.statusCode}"); + throw "status code ${response.statusCode}"; } } outputDir = await installationDirectory.createTemp("reboot_out"); final tempZip = File("${outputDir.path}\\reboot.zip"); - await tempZip.writeAsBytes(response.bodyBytes, flush: true); - await extractFileToDisk(tempZip.path, outputDir.path); - final rebootDll = File(outputDir.listSync().firstWhere((element) => path.extension(element.path) == ".dll").path); - await file.writeAsBytes(await rebootDll.readAsBytes(), flush: true); + + try { + await tempZip.writeAsBytes(response.bodyBytes, flush: true); // Write reboot.zip to disk + + await tempZip.readAsBytes(); // Check implicitly if antivirus doesn't like reboot + + await extractFileToDisk(tempZip.path, outputDir.path); + + final rebootDll = outputDir.listSync() + .firstWhere((element) => path.extension(element.path) == ".dll") as File; + final rebootDllSource = await rebootDll.readAsBytes(); + await file.writeAsBytes(rebootDllSource, flush: true); + + await file.readAsBytes(); // Check implicitly if antivirus doesn't like reboot + + return true; + } catch(_) { + return false; // Anti virus probably flagged reboot + } } finally{ if(outputDir != null) { delete(outputDir); diff --git a/gui/lib/src/controller/dll_controller.dart b/gui/lib/src/controller/dll_controller.dart index 1960d04..a5dd46d 100644 --- a/gui/lib/src/controller/dll_controller.dart +++ b/gui/lib/src/controller/dll_controller.dart @@ -105,14 +105,25 @@ class DllController extends GetxController { duration: null ); } - await Future.wait( + final result = await Future.wait( [ downloadRebootDll(rebootBeforeS20DllFile, beforeS20Mirror.text, false), downloadRebootDll(rebootAboveS20DllFile, aboveS20Mirror.text, true), Future.delayed(const Duration(seconds: 1)) + .then((_) => true) ], eagerError: false - ); + ).then((values) => values.reduce((first, second) => first && second)); + if(!result) { + status.value = UpdateStatus.error; + showRebootInfoBar( + translations.downloadDllAntivirus(antiVirusName ?? defaultAntiVirusName, "reboot"), + duration: infoBarLongDuration, + severity: InfoBarSeverity.error + ); + infoBarEntry?.close(); + return false; + } timestamp.value = DateTime.now().millisecondsSinceEpoch; status.value = UpdateStatus.success; infoBarEntry?.close();