Add extra logging info

This commit is contained in:
pizzaboxer 2023-07-26 11:21:54 +01:00
parent 102f6d1949
commit a3fd58118d
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
4 changed files with 24 additions and 11 deletions

View File

@ -99,6 +99,8 @@ namespace Bloxstrap
else else
Logger.WriteLine(LOG_IDENT, $"Compiled {BuildMetadata.Timestamp.ToFriendlyString()} from commit {BuildMetadata.CommitHash} ({BuildMetadata.CommitRef})"); 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, // To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration. // see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize(); ApplicationConfiguration.Initialize();

View File

@ -1039,7 +1039,7 @@ namespace Bloxstrap
// emoji presets are downloaded remotely from github due to how large they are // emoji presets are downloaded remotely from github due to how large they are
string contentFonts = Path.Combine(Paths.Modifications, "content\\fonts"); string contentFonts = Path.Combine(Paths.Modifications, "content\\fonts");
string emojiFontLocation = Path.Combine(contentFonts, "TwemojiMozilla.ttf"); 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)) 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) 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 fullLocation = Path.Combine(Paths.Modifications, location);
string fileHash = File.Exists(fullLocation) ? MD5Hash.FromFile(fullLocation) : ""; string fileHash = File.Exists(fullLocation) ? MD5Hash.FromFile(fullLocation) : "";
@ -1185,14 +1187,19 @@ namespace Bloxstrap
if (!condition) 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); File.Delete(fullLocation);
}
return; return;
} }
if (fileHash != embeddedHash) 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)!); Directory.CreateDirectory(Path.GetDirectoryName(fullLocation)!);
File.Delete(fullLocation); File.Delete(fullLocation);
@ -1294,7 +1301,7 @@ namespace Bloxstrap
string packageLocation = Path.Combine(Paths.Downloads, package.Signature); string packageLocation = Path.Combine(Paths.Downloads, package.Signature);
string packageFolder = Path.Combine(_versionFolder, PackageDirectories[package.Name]); 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<ZipArchive>(() => ZipFile.OpenRead(packageLocation)); var readTask = new Task<ZipArchive>(() => ZipFile.OpenRead(packageLocation));
_ = readTask.ContinueWith(AsyncHelpers.ExceptionHandler, $"reading {package.Name}"); _ = readTask.ContinueWith(AsyncHelpers.ExceptionHandler, $"reading {package.Name}");
@ -1302,6 +1309,8 @@ namespace Bloxstrap
using ZipArchive archive = await readTask.WaitAsync(TimeSpan.FromSeconds(30)); 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 // 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, // 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... // empty folders that *BEGIN* with a backslash in their fullname, but have an empty name are listed here for some reason...

View File

@ -10,6 +10,8 @@
public static string StartMenu => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Programs", App.ProjectName); 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 System => Environment.GetFolderPath(Environment.SpecialFolder.System);
public static string Process => Environment.ProcessPath!;
public static string Base { get; private set; } = ""; public static string Base { get; private set; } = "";
public static string Downloads { get; private set; } = ""; public static string Downloads { get; private set; } = "";
public static string Logs { get; private set; } = ""; public static string Logs { get; private set; } = "";

View File

@ -8,15 +8,15 @@ namespace Bloxstrap
{ {
const string LOG_IDENT = "Updater::CheckInstalledVersion"; 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; return;
// 2.0.0 downloads updates to <BaseFolder>/Updates so lol // 2.0.0 downloads updates to <BaseFolder>/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; return;
MessageBoxResult result; MessageBoxResult result;
@ -65,7 +65,7 @@ namespace Bloxstrap
return; return;
} }
File.Copy(Environment.ProcessPath, Paths.Application); File.Copy(Paths.Process, Paths.Application);
Bootstrapper.Register(); Bootstrapper.Register();