From 9a412ea17bf944f309d2ee33c6d286c9f005615b Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Tue, 27 Aug 2024 12:53:03 +0100 Subject: [PATCH] Warn about in-place downgrades --- Bloxstrap/App.xaml.cs | 2 ++ Bloxstrap/Installer.cs | 15 +++++++++++++++ Bloxstrap/Resources/Strings.Designer.cs | 11 +++++++++++ Bloxstrap/Resources/Strings.resx | 5 +++++ 4 files changed, 33 insertions(+) diff --git a/Bloxstrap/App.xaml.cs b/Bloxstrap/App.xaml.cs index 1ad9b693..f244c7c9 100644 --- a/Bloxstrap/App.xaml.cs +++ b/Bloxstrap/App.xaml.cs @@ -220,8 +220,10 @@ protected override void OnStartup(StartupEventArgs e) Locale.Set(Settings.Prop.Locale); +#if !DEBUG if (!LaunchSettings.UninstallFlag.Active) Installer.HandleUpgrade(); +#endif LaunchHandler.ProcessLaunchArgs(); } diff --git a/Bloxstrap/Installer.cs b/Bloxstrap/Installer.cs index ccb458cc..849a834b 100644 --- a/Bloxstrap/Installer.cs +++ b/Bloxstrap/Installer.cs @@ -340,6 +340,18 @@ public static void HandleUpgrade() if (MD5Hash.FromFile(Paths.Process) == MD5Hash.FromFile(Paths.Application)) return; + if (currentVer is not null && existingVer is not null && Utilities.CompareVersions(currentVer, existingVer) == VersionComparison.LessThan) + { + var result = Frontend.ShowMessageBox( + Strings.InstallChecker_VersionLessThanInstalled, + MessageBoxImage.Question, + MessageBoxButton.YesNo + ); + + if (result != MessageBoxResult.Yes) + return; + } + // silently upgrade version if the command line flag is set or if we're launching from an auto update if (!App.LaunchSettings.UpgradeFlag.Active && !isAutoUpgrade) { @@ -466,6 +478,9 @@ public static void HandleUpgrade() App.FastFlags.Save(); } + if (currentVer is null) + return; + if (isAutoUpgrade) { Utilities.ShellExecute($"https://github.com/{App.ProjectRepository}/wiki/Release-notes-for-Bloxstrap-v{currentVer}"); diff --git a/Bloxstrap/Resources/Strings.Designer.cs b/Bloxstrap/Resources/Strings.Designer.cs index 8a77c154..61592fe9 100644 --- a/Bloxstrap/Resources/Strings.Designer.cs +++ b/Bloxstrap/Resources/Strings.Designer.cs @@ -1276,6 +1276,17 @@ public static string InstallChecker_VersionDifferentThanInstalled { } } + /// + /// Looks up a localized string similar to The version of Bloxstrap you've launched is older than the version you currently have installed. + ///Issues may occur and your settings may be altered. A reinstall is recommended. + ///Are you sure you want to continue?. + /// + public static string InstallChecker_VersionLessThanInstalled { + get { + return ResourceManager.GetString("InstallChecker.VersionLessThanInstalled", resourceCulture); + } + } + /// /// Looks up a localized string similar to Will drop you into the desktop app once everything's done. /// diff --git a/Bloxstrap/Resources/Strings.resx b/Bloxstrap/Resources/Strings.resx index 0b018596..70f23a25 100644 --- a/Bloxstrap/Resources/Strings.resx +++ b/Bloxstrap/Resources/Strings.resx @@ -1142,4 +1142,9 @@ If not, then please report this exception to the maintainers of this fork. Do NO You have unsaved changes. Are you sure you want to close without saving? + + The version of Bloxstrap you've launched is older than the version you currently have installed. +Issues may occur and your settings may be altered. A reinstall is recommended. +Are you sure you want to continue? + \ No newline at end of file