bring back the old roblox version directory (#3908)

This commit is contained in:
Matt 2024-12-06 13:59:26 +00:00 committed by GitHub
parent f4cb8b48c0
commit 78882ec1ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 106 additions and 102 deletions

View File

@ -42,13 +42,13 @@ namespace Bloxstrap.AppData
};
public virtual string ExecutableName { get; } = null!;
public virtual string Directory { get; } = null!;
public string LockFilePath => Path.Combine(Directory, "Bloxstrap.lock");
public string Directory => Path.Combine(Paths.Versions, State.VersionGuid);
public string ExecutablePath => Path.Combine(Directory, ExecutableName);
public virtual AppState State { get; } = null!;
public virtual IReadOnlyDictionary<string, string> PackageDirectoryMap { get; set; }

View File

@ -12,10 +12,6 @@
string Directory { get; }
string OldDirectory { get; }
string LockFilePath { get; }
string ExecutablePath { get; }
AppState State { get; }

View File

@ -16,11 +16,7 @@ namespace Bloxstrap.AppData
public override string ExecutableName => "RobloxPlayerBeta.exe";
public override string Directory => Path.Combine(Paths.Roblox, "Player");
public string OldDirectory => Path.Combine(Paths.Roblox, "Player.old");
public AppState State => App.State.Prop.Player;
public override AppState State => App.State.Prop.Player;
public override IReadOnlyDictionary<string, string> PackageDirectoryMap { get; set; } = new Dictionary<string, string>()
{

View File

@ -10,11 +10,7 @@
public override string ExecutableName => "RobloxStudioBeta.exe";
public override string Directory => Path.Combine(Paths.Roblox, "Studio");
public string OldDirectory => Path.Combine(Paths.Roblox, "Studio.old");
public AppState State => App.State.Prop.Studio;
public override AppState State => App.State.Prop.Studio;
public override IReadOnlyDictionary<string, string> PackageDirectoryMap { get; set; } = new Dictionary<string, string>()
{

View File

@ -7,8 +7,8 @@
<UseWPF>true</UseWPF>
<UseWindowsForms>True</UseWindowsForms>
<ApplicationIcon>Bloxstrap.ico</ApplicationIcon>
<Version>2.8.1</Version>
<FileVersion>2.8.1</FileVersion>
<Version>2.8.2</Version>
<FileVersion>2.8.2</FileVersion>
<ApplicationManifest>app.manifest</ApplicationManifest>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>

View File

@ -50,6 +50,7 @@ namespace Bloxstrap
private string _launchCommandLine = App.LaunchSettings.RobloxLaunchArgs;
private string _latestVersionGuid = null!;
private string _latestVersionDirectory = null!;
private PackageManifest _versionPackageManifest = null!;
private bool _isInstalling = false;
@ -58,7 +59,7 @@ namespace Bloxstrap
private double _taskbarProgressMaximum;
private long _totalDownloadedBytes = 0;
private bool _mustUpgrade => String.IsNullOrEmpty(AppData.State.VersionGuid) || File.Exists(AppData.LockFilePath) || !File.Exists(AppData.ExecutablePath);
private bool _mustUpgrade => String.IsNullOrEmpty(AppData.State.VersionGuid) || !File.Exists(AppData.ExecutablePath);
private bool _noConnection = false;
private AsyncMutex? _mutex;
@ -313,6 +314,7 @@ namespace Bloxstrap
key.SetValueSafe("www.roblox.com", Deployment.IsDefaultChannel ? "" : Deployment.Channel);
_latestVersionGuid = clientVersion.VersionGuid;
_latestVersionDirectory = Path.Combine(Paths.Versions, _latestVersionGuid);
string pkgManifestUrl = Deployment.GetLocation($"/{_latestVersionGuid}-rbxPkgManifest.txt");
var pkgManifestData = await App.HttpClient.GetStringAsync(pkgManifestUrl);
@ -513,18 +515,13 @@ namespace Bloxstrap
try
{
// clean up install
if (Directory.Exists(AppData.Directory))
Directory.Delete(AppData.Directory, true);
if (Directory.Exists(_latestVersionDirectory))
Directory.Delete(_latestVersionDirectory, true);
}
catch (Exception ex)
{
App.Logger.WriteLine(LOG_IDENT, "Could not fully clean up installation!");
App.Logger.WriteException(LOG_IDENT, ex);
// assurance to make sure the next launch does a fresh install
// we probably shouldn't be using the lockfile to do this, but meh
var lockFile = new FileInfo(AppData.LockFilePath);
lockFile.Create().Dispose();
}
}
else if (_appPid != 0)
@ -649,9 +646,51 @@ namespace Bloxstrap
return false;
}
#endregion
#endregion
#region Roblox Install
private void CleanupVersionsFolder()
{
const string LOG_IDENT = "Bootstrapper::CleanupVersionsFolder";
foreach (string dir in Directory.GetDirectories(Paths.Versions))
{
string dirName = Path.GetFileName(dir);
if (dirName != App.State.Prop.Player.VersionGuid && dirName != App.State.Prop.Studio.VersionGuid)
{
try
{
Directory.Delete(dir, true);
}
catch (IOException ex)
{
App.Logger.WriteLine(LOG_IDENT, $"Failed to delete {dir}");
App.Logger.WriteException(LOG_IDENT, ex);
}
}
}
}
private void MigrateCompatibilityFlags()
{
const string LOG_IDENT = "Bootstrapper::MigrateCompatibilityFlags";
string oldClientLocation = Path.Combine(Paths.Versions, AppData.State.VersionGuid, AppData.ExecutableName);
string newClientLocation = Path.Combine(_latestVersionDirectory, AppData.ExecutableName);
// move old compatibility flags for the old location
using RegistryKey appFlagsKey = Registry.CurrentUser.CreateSubKey($"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers");
string? appFlags = appFlagsKey.GetValue(oldClientLocation) as string;
if (appFlags is not null)
{
App.Logger.WriteLine(LOG_IDENT, $"Migrating app compatibility flags from {oldClientLocation} to {newClientLocation}...");
appFlagsKey.SetValueSafe(newClientLocation, appFlags);
appFlagsKey.DeleteValueSafe(oldClientLocation);
}
}
private async Task UpgradeRoblox()
{
const string LOG_IDENT = "Bootstrapper::UpgradeRoblox";
@ -663,55 +702,11 @@ namespace Bloxstrap
Directory.CreateDirectory(Paths.Base);
Directory.CreateDirectory(Paths.Downloads);
Directory.CreateDirectory(Paths.Roblox);
if (Directory.Exists(AppData.Directory))
{
if (Directory.Exists(AppData.OldDirectory))
Directory.Delete(AppData.OldDirectory, true);
try
{
// test to see if any files are in use
// if you have a better way to check for this, please let me know!
Directory.Move(AppData.Directory, AppData.OldDirectory);
}
catch (Exception ex)
{
App.Logger.WriteLine(LOG_IDENT, "Could not clear old files, aborting update.");
App.Logger.WriteException(LOG_IDENT, ex);
// 0x80070020 is the HRESULT that indicates that a process is still running
// (either RobloxPlayerBeta or RobloxCrashHandler), so we'll silently ignore it
if ((uint)ex.HResult != 0x80070020)
{
// ensure no files are marked as read-only for good measure
foreach (var file in Directory.GetFiles(AppData.Directory, "*", SearchOption.AllDirectories))
Filesystem.AssertReadOnly(file);
Frontend.ShowMessageBox(
Strings.Bootstrapper_FilesInUse,
_mustUpgrade ? MessageBoxImage.Error : MessageBoxImage.Warning
);
if (_mustUpgrade)
App.Terminate(ErrorCode.ERROR_CANCELLED);
}
return;
}
Directory.Delete(AppData.OldDirectory, true);
}
Directory.CreateDirectory(Paths.Versions);
_isInstalling = true;
Directory.CreateDirectory(AppData.Directory);
// installer lock, it should only be present while roblox is in the process of upgrading
// if it's present while we're launching, then it's an unfinished install and must be reinstalled
var lockFile = new FileInfo(AppData.LockFilePath);
lockFile.Create().Dispose();
Directory.CreateDirectory(_latestVersionDirectory);
var cachedPackageHashes = Directory.GetFiles(Paths.Downloads).Select(x => Path.GetFileName(x));
@ -779,7 +774,7 @@ namespace Bloxstrap
await Task.WhenAll(extractionTasks);
App.Logger.WriteLine(LOG_IDENT, "Writing AppSettings.xml...");
await File.WriteAllTextAsync(Path.Combine(AppData.Directory, "AppSettings.xml"), AppSettings);
await File.WriteAllTextAsync(Path.Combine(_latestVersionDirectory, "AppSettings.xml"), AppSettings);
if (_cancelTokenSource.IsCancellationRequested)
return;
@ -814,7 +809,7 @@ namespace Bloxstrap
return;
}
string baseDirectory = Path.Combine(AppData.Directory, AppData.PackageDirectoryMap[package.Name]);
string baseDirectory = Path.Combine(_latestVersionDirectory, AppData.PackageDirectoryMap[package.Name]);
ExtractPackage(package);
@ -838,6 +833,8 @@ namespace Bloxstrap
// finishing and cleanup
MigrateCompatibilityFlags();
AppData.State.VersionGuid = _latestVersionGuid;
AppData.State.PackageHashes.Clear();
@ -845,6 +842,8 @@ namespace Bloxstrap
foreach (var package in _versionPackageManifest)
AppData.State.PackageHashes.Add(package.Name, package.Signature);
CleanupVersionsFolder();
var allPackageHashes = new List<string>();
allPackageHashes.AddRange(App.State.Prop.Player.PackageHashes.Values);
@ -885,8 +884,6 @@ namespace Bloxstrap
App.State.Save();
lockFile.Delete();
_isInstalling = false;
}
@ -919,7 +916,7 @@ namespace Bloxstrap
const string path = "rbxasset://fonts/CustomFont.ttf";
foreach (string jsonFilePath in Directory.GetFiles(Path.Combine(AppData.Directory, "content\\fonts\\families")))
foreach (string jsonFilePath in Directory.GetFiles(Path.Combine(_latestVersionDirectory, "content\\fonts\\families")))
{
string jsonFilename = Path.GetFileName(jsonFilePath);
string modFilepath = Path.Combine(modFontFamiliesFolder, jsonFilename);
@ -980,7 +977,7 @@ namespace Bloxstrap
modFolderFiles.Add(relativeFile);
string fileModFolder = Path.Combine(Paths.Modifications, relativeFile);
string fileVersionFolder = Path.Combine(AppData.Directory, relativeFile);
string fileVersionFolder = Path.Combine(_latestVersionDirectory, relativeFile);
if (File.Exists(fileVersionFolder) && MD5Hash.FromFile(fileModFolder) == MD5Hash.FromFile(fileVersionFolder))
{
@ -1016,7 +1013,7 @@ namespace Bloxstrap
{
App.Logger.WriteLine(LOG_IDENT, $"{fileLocation} was removed as a mod but does not belong to a package");
string versionFileLocation = Path.Combine(AppData.Directory, fileLocation);
string versionFileLocation = Path.Combine(_latestVersionDirectory, fileLocation);
if (File.Exists(versionFileLocation))
File.Delete(versionFileLocation);
@ -1204,7 +1201,7 @@ namespace Bloxstrap
return;
}
string packageFolder = Path.Combine(AppData.Directory, packageDir);
string packageFolder = Path.Combine(_latestVersionDirectory, packageDir);
string? fileFilter = null;
// for sharpziplib, each file in the filter needs to be a regex

View File

@ -17,5 +17,19 @@ namespace Bloxstrap.Extensions
App.Terminate(ErrorCode.ERROR_INSTALL_FAILURE);
}
}
public static void DeleteValueSafe(this RegistryKey registryKey, string name)
{
try
{
App.Logger.WriteLine("RegistryKeyEx::DeleteValueSafe", $"Deleting {registryKey}\\{name}");
registryKey.DeleteValue(name);
}
catch (UnauthorizedAccessException)
{
Frontend.ShowMessageBox(Strings.Dialog_RegistryWriteError, System.Windows.MessageBoxImage.Error);
App.Terminate(ErrorCode.ERROR_INSTALL_FAILURE);
}
}
}
}

View File

@ -287,8 +287,8 @@ namespace Bloxstrap
() => File.Delete(StartMenuShortcut),
() => Directory.Delete(Paths.Versions, true),
() => Directory.Delete(Paths.Downloads, true),
() => Directory.Delete(Paths.Roblox, true),
() => File.Delete(App.State.FileLocation)
};
@ -547,15 +547,6 @@ namespace Bloxstrap
App.FastFlags.SetValue("FFlagDisableNewIGMinDUA", null);
App.FastFlags.SetValue("FFlagFixGraphicsQuality", null);
try
{
Directory.Delete(Path.Combine(Paths.Base, "Versions"), true);
}
catch (Exception ex)
{
App.Logger.WriteException(LOG_IDENT, ex);
}
}
if (Utilities.CompareVersions(existingVer, "2.8.1") == VersionComparison.LessThan)
@ -572,6 +563,17 @@ namespace Bloxstrap
App.FastFlags.SetValue("FFlagEnableInGameMenuChromeABTest4", null);
}
if (Utilities.CompareVersions(existingVer, "2.8.2") == VersionComparison.LessThan)
{
try
{
Directory.Delete(Path.Combine(Paths.Base, "Roblox"), true);
}
catch (Exception ex)
{
App.Logger.WriteException(LOG_IDENT, ex);
}
}
App.Settings.Save();
App.FastFlags.Save();

View File

@ -1,6 +1,7 @@
using System.Web;
using System.Windows;
using System.Windows.Input;
using Bloxstrap.AppData;
using Bloxstrap.Models.APIs;
using CommunityToolkit.Mvvm.Input;
@ -149,7 +150,7 @@ namespace Bloxstrap.Models.Entities
private void RejoinServer()
{
string playerPath = Path.Combine(Paths.Roblox, "Player", "RobloxPlayerBeta.exe");
string playerPath = new RobloxPlayerData().ExecutablePath;
Process.Start(playerPath, GetInviteDeeplink(false));
}

View File

@ -20,8 +20,8 @@
public static string Downloads { get; private set; } = "";
public static string Logs { get; private set; } = "";
public static string Integrations { get; private set; } = "";
public static string Versions { get; private set; } = "";
public static string Modifications { get; private set; } = "";
public static string Roblox { get; private set; } = "";
public static string Application { get; private set; } = "";
@ -35,8 +35,8 @@
Downloads = Path.Combine(Base, "Downloads");
Logs = Path.Combine(Base, "Logs");
Integrations = Path.Combine(Base, "Integrations");
Versions = Path.Combine(Base, "Versions");
Modifications = Path.Combine(Base, "Modifications");
Roblox = Path.Combine(Base, "Roblox");
Application = Path.Combine(Base, $"{App.ProjectName}.exe");
}

View File

@ -1,4 +1,5 @@
using System.ComponentModel;
using Bloxstrap.AppData;
using System.ComponentModel;
namespace Bloxstrap
{
@ -64,9 +65,9 @@ namespace Bloxstrap
public static string GetRobloxVersion(bool studio)
{
string fileName = studio ? "Studio/RobloxStudioBeta.exe" : "Player/RobloxPlayerBeta.exe";
IAppData data = studio ? new RobloxStudioData() : new RobloxPlayerData();
string playerLocation = Path.Combine(Paths.Roblox, fileName);
string playerLocation = data.ExecutablePath;
if (!File.Exists(playerLocation))
return "";

View File

@ -1,4 +1,5 @@
using Bloxstrap.Integrations;
using Bloxstrap.AppData;
using Bloxstrap.Integrations;
using Bloxstrap.Models;
namespace Bloxstrap
@ -30,7 +31,7 @@ namespace Bloxstrap
#if DEBUG
if (String.IsNullOrEmpty(watcherDataArg))
{
string path = Path.Combine(Paths.Roblox, "Player", "RobloxPlayerBeta.exe");
string path = new RobloxPlayerData().ExecutablePath;
using var gameClientProcess = Process.Start(path);
_watcherData = new() { ProcessId = gameClientProcess.Id };