diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.StateMachine.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.StateMachine.cs
index 5bd78df..c0abd30 100644
--- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.StateMachine.cs
+++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.StateMachine.cs
@@ -284,14 +284,16 @@ namespace AM2RLauncher
// If we have a cache, return that instead
if (isAM2R11InstalledCache != null) return isAM2R11InstalledCache.Value;
+ string am2r11file = CrossPlatformOperations.CURRENTPATH + "/AM2R_11.zip";
// Return safely if file doesn't exist
- if (!File.Exists(CrossPlatformOperations.CURRENTPATH + "/AM2R_11.zip")) return false;
- var returnCode = HelperMethods.CheckIfZipIsAM2R11(CrossPlatformOperations.CURRENTPATH + "/AM2R_11.zip");
+ if (!File.Exists(am2r11file)) return false;
+ lastAM2R11ZipMD5 = HelperMethods.CalculateMD5(am2r11file);
+ var returnCode = HelperMethods.CheckIfZipIsAM2R11(am2r11file);
// 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);
- HelperMethods.RecursiveRollover(CrossPlatformOperations.CURRENTPATH + "/AM2R_11.zip");
+ HelperMethods.RecursiveRollover(am2r11file);
isAM2R11InstalledCache = false;
return false;
}
@@ -304,6 +306,11 @@ namespace AM2RLauncher
///
public static void InvalidateAM2R11InstallCache()
{
+ // If the file exists, and its hash matches with ours, don't invalidate
+ if (File.Exists(CrossPlatformOperations.CURRENTPATH + "/AM2R_11.zip") &&
+ HelperMethods.CalculateMD5(CrossPlatformOperations.CURRENTPATH + "/AM2R_11.zip") == lastAM2R11ZipMD5)
+ return;
+
isAM2R11InstalledCache = null;
}
diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs
index c3ebdbb..3c45d20 100644
--- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs
+++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs
@@ -95,6 +95,12 @@ namespace AM2RLauncher
///
static private bool? isAM2R11InstalledCache = null;
+ ///
+ /// Caches the MD5 hash of the provided AM2R_11.zip so we don't end up checking the zip if it hasn't changed.
+ ///
+ //TODO: worth reading / writing to config?
+ static private string lastAM2R11ZipMD5 = "";
+
///
/// Checks if the AM2RLauncher is run via WINE.
///