Fix potential bug in install checker

UB would occur if installer.CheckInstallLocation() failed when attempting to change the install location
This commit is contained in:
pizzaboxer 2024-09-09 12:09:44 +01:00
parent 62064117b6
commit 356155c75b
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
2 changed files with 24 additions and 17 deletions

View File

@ -198,14 +198,7 @@ namespace Bloxstrap
} }
} }
if (installLocation is null) if (fixInstallLocation && installLocation is not null)
{
Logger.Initialize(true);
LaunchHandler.LaunchInstaller();
}
else
{
if (fixInstallLocation)
{ {
var installer = new Installer var installer = new Installer
{ {
@ -218,8 +211,20 @@ namespace Bloxstrap
Logger.WriteLine(LOG_IDENT, $"Changing install location to '{installLocation}'"); Logger.WriteLine(LOG_IDENT, $"Changing install location to '{installLocation}'");
installer.DoInstall(); installer.DoInstall();
} }
else
{
// force reinstall
installLocation = null;
}
} }
if (installLocation is null)
{
Logger.Initialize(true);
LaunchHandler.LaunchInstaller();
}
else
{
Paths.Initialize(installLocation); Paths.Initialize(installLocation);
// ensure executable is in the install directory // ensure executable is in the install directory
@ -246,10 +251,8 @@ namespace Bloxstrap
Locale.Set(Settings.Prop.Locale); Locale.Set(Settings.Prop.Locale);
#if !DEBUG
if (!LaunchSettings.BypassUpdateCheck) if (!LaunchSettings.BypassUpdateCheck)
Installer.HandleUpgrade(); Installer.HandleUpgrade();
#endif
LaunchHandler.ProcessLaunchArgs(); LaunchHandler.ProcessLaunchArgs();
} }

View File

@ -28,7 +28,11 @@ namespace Bloxstrap
public LaunchFlag StudioFlag { get; } = new("studio"); public LaunchFlag StudioFlag { get; } = new("studio");
#if DEBUG
public bool BypassUpdateCheck => true;
#else
public bool BypassUpdateCheck => UninstallFlag.Active || WatcherFlag.Active; public bool BypassUpdateCheck => UninstallFlag.Active || WatcherFlag.Active;
#endif
public LaunchMode RobloxLaunchMode { get; set; } = LaunchMode.None; public LaunchMode RobloxLaunchMode { get; set; } = LaunchMode.None;