From 4cda4d7fa23dfe5b0482c987b61db355197f2329 Mon Sep 17 00:00:00 2001 From: Miepee <38186597+Miepee@users.noreply.github.com> Date: Thu, 5 Aug 2021 15:12:18 +0200 Subject: [PATCH] Expand Is11Installed to check for valid Zips instead of just zips. --- .../AM2RLauncher/MainForm/MainForm.Methods.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Methods.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Methods.cs index 51c96a8..c5f8744 100644 --- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Methods.cs +++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Methods.cs @@ -30,12 +30,20 @@ namespace AM2RLauncher } /// - /// Checks if AM2R 1.1 has been installed already, aka if the AM2R 1.1 Zip exists. + /// Checks if AM2R 1.1 has been installed already, aka if a valid AM2R 1.1 Zip exists. /// /// if yes, if not. private bool Is11Installed() { - return File.Exists(CrossPlatformOperations.CURRENTPATH + "/AM2R_11.zip"); + var returnCode = CheckIfZipIsAM2R11(CrossPlatformOperations.CURRENTPATH + "/AM2R_11.zip"); + // Check if it's valid, if not log it, rename it and silently leave + if (returnCode != IsZipAM2R11ReturnCodes.Successful) + { + log.Info("Detected invalid AM2R_11 zip with following error code: " + returnCode); + RecursiveRollover(CrossPlatformOperations.CURRENTPATH + "/AM2R_11.zip"); + return false; + } + return true; } /// @@ -799,8 +807,8 @@ namespace AM2RLauncher /// Performs recursive rollover on a set of log files. /// /// The log file to begin the rollover from. - /// The maximum amount of log files to retain. - private void RecursiveRollover(string logFile, int max) + /// The maximum amount of log files to retain. Default is int.MaxValue, in other words, never delete files. + private void RecursiveRollover(string logFile, int max = int.MaxValue) { int index = 1; char endChar = logFile[logFile.Length - 1];