diff --git a/Bloxstrap/App.xaml.cs b/Bloxstrap/App.xaml.cs index 9d6ea5a..bf958dd 100644 --- a/Bloxstrap/App.xaml.cs +++ b/Bloxstrap/App.xaml.cs @@ -99,6 +99,8 @@ namespace Bloxstrap else Logger.WriteLine(LOG_IDENT, $"Compiled {BuildMetadata.Timestamp.ToFriendlyString()} from commit {BuildMetadata.CommitHash} ({BuildMetadata.CommitRef})"); + Logger.WriteLine(LOG_IDENT, $"Loaded from {Paths.Process}"); + // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index aeb2f10..517b86a 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -1039,7 +1039,7 @@ namespace Bloxstrap // emoji presets are downloaded remotely from github due to how large they are string contentFonts = Path.Combine(Paths.Modifications, "content\\fonts"); string emojiFontLocation = Path.Combine(contentFonts, "TwemojiMozilla.ttf"); - string emojiFontHash = File.Exists(emojiFontLocation) ? Utility.MD5Hash.FromFile(emojiFontLocation) : ""; + string emojiFontHash = File.Exists(emojiFontLocation) ? MD5Hash.FromFile(emojiFontLocation) : ""; if (App.Settings.Prop.EmojiType == EmojiType.Default && EmojiTypeEx.Hashes.Values.Contains(emojiFontHash)) { @@ -1174,6 +1174,8 @@ namespace Bloxstrap private static async Task CheckModPreset(bool condition, string location, string name) { + string LOG_IDENT = $"Bootstrapper::CheckModPreset.{name}"; + string fullLocation = Path.Combine(Paths.Modifications, location); string fileHash = File.Exists(fullLocation) ? MD5Hash.FromFile(fullLocation) : ""; @@ -1185,14 +1187,19 @@ namespace Bloxstrap if (!condition) { - if (fileHash != "" && fileHash == embeddedHash) + if (fileHash == embeddedHash) + { + App.Logger.WriteLine(LOG_IDENT, $"Deleting '{location}' as preset is disabled, and mod file matches preset"); File.Delete(fullLocation); - + } + return; } if (fileHash != embeddedHash) - { + { + App.Logger.WriteLine(LOG_IDENT, $"Writing '{location}' as preset is enabled, and mod file does not exist or does not match preset"); + Directory.CreateDirectory(Path.GetDirectoryName(fullLocation)!); File.Delete(fullLocation); @@ -1294,14 +1301,16 @@ namespace Bloxstrap string packageLocation = Path.Combine(Paths.Downloads, package.Signature); string packageFolder = Path.Combine(_versionFolder, PackageDirectories[package.Name]); - App.Logger.WriteLine(LOG_IDENT, $"Extracting {package.Name} to {packageFolder}..."); + App.Logger.WriteLine(LOG_IDENT, $"Reading {package.Name}..."); var readTask = new Task(() => ZipFile.OpenRead(packageLocation)); _ = readTask.ContinueWith(AsyncHelpers.ExceptionHandler, $"reading {package.Name}"); readTask.Start(); using ZipArchive archive = await readTask.WaitAsync(TimeSpan.FromSeconds(30)); - + + App.Logger.WriteLine(LOG_IDENT, $"Read {package.Name}. Extracting to {packageFolder}..."); + // yeah so because roblox is roblox, these packages aren't actually valid zip files // besides the fact that they use backslashes instead of forward slashes for directories, // empty folders that *BEGIN* with a backslash in their fullname, but have an empty name are listed here for some reason... diff --git a/Bloxstrap/Paths.cs b/Bloxstrap/Paths.cs index db8ea79..ecdc71c 100644 --- a/Bloxstrap/Paths.cs +++ b/Bloxstrap/Paths.cs @@ -10,6 +10,8 @@ public static string StartMenu => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Programs", App.ProjectName); public static string System => Environment.GetFolderPath(Environment.SpecialFolder.System); + public static string Process => Environment.ProcessPath!; + public static string Base { get; private set; } = ""; public static string Downloads { get; private set; } = ""; public static string Logs { get; private set; } = ""; diff --git a/Bloxstrap/Updater.cs b/Bloxstrap/Updater.cs index 41ac472..45e1db9 100644 --- a/Bloxstrap/Updater.cs +++ b/Bloxstrap/Updater.cs @@ -8,15 +8,15 @@ namespace Bloxstrap { const string LOG_IDENT = "Updater::CheckInstalledVersion"; - if (Environment.ProcessPath is null || !File.Exists(Paths.Application) || Environment.ProcessPath == Paths.Application) + if (!File.Exists(Paths.Application) || Paths.Process == Paths.Application) return; // 2.0.0 downloads updates to /Updates so lol - bool isAutoUpgrade = Environment.ProcessPath.StartsWith(Path.Combine(Paths.Base, "Updates")) || Environment.ProcessPath.StartsWith(Path.Combine(Paths.LocalAppData, "Temp")); + bool isAutoUpgrade = Paths.Process.StartsWith(Path.Combine(Paths.Base, "Updates")) || Paths.Process.StartsWith(Path.Combine(Paths.LocalAppData, "Temp")); - FileVersionInfo currentVersionInfo = FileVersionInfo.GetVersionInfo(Environment.ProcessPath); + FileVersionInfo currentVersionInfo = FileVersionInfo.GetVersionInfo(Paths.Process); - if (MD5Hash.FromFile(Environment.ProcessPath) == MD5Hash.FromFile(Paths.Application)) + if (MD5Hash.FromFile(Paths.Process) == MD5Hash.FromFile(Paths.Application)) return; MessageBoxResult result; @@ -65,7 +65,7 @@ namespace Bloxstrap return; } - File.Copy(Environment.ProcessPath, Paths.Application); + File.Copy(Paths.Process, Paths.Application); Bootstrapper.Register();