diff --git a/ModpackUpdater.Apps.Client/Program.cs b/ModpackUpdater.Apps.Client/Program.cs index 109e37d..bf8205e 100644 --- a/ModpackUpdater.Apps.Client/Program.cs +++ b/ModpackUpdater.Apps.Client/Program.cs @@ -12,9 +12,12 @@ namespace ModpackUpdater.Apps.Client; public static class Program { private static readonly SettingsManager settingsManager; + private static readonly ILogger log = new ConsoleLogger(); public static ISettings Settings => settingsManager.Instance; + public static ILogger Log => log; + [DllImport("kernel32.dll")] static extern nint GetConsoleWindow(); @@ -100,21 +103,21 @@ public static class Program // Check for update var installer = new ModpackInstaller(config, info) { - Log = new ConsoleLogger(), + Log = Log, }; var result = installer.Check(updateOptions).Result; if (!silent && !updateOptions.NoUpdate && new AppUpdater().Check().Result) - Console.WriteLine("A new version is available!"); + Log.Info("A new version is available!"); if (result.HasUpdates) { var success = installer.Install(result).Result; if (!silent) - Console.WriteLine($"Installation {(success ?? false ? "completed successfully" : "failed")}!"); + Log.Info($"Installation {(success ?? false ? "completed successfully" : "failed")}!"); } else if (!silent) - Console.WriteLine("No updates available"); + Log.Info("No updates available"); } private static string CheckModpackConfigUrl(string configUrl, ModpackInfo info) diff --git a/ModpackUpdater.Manager/ModpackInstaller.cs b/ModpackUpdater.Manager/ModpackInstaller.cs index 9aab986..dff31a1 100644 --- a/ModpackUpdater.Manager/ModpackInstaller.cs +++ b/ModpackUpdater.Manager/ModpackInstaller.cs @@ -62,8 +62,7 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf } installInfos = await DownloadInstallInfos(); - result.CurrentVersion = modpackInfo.Version ?? installInfos.Version; - var curVersion = result.CurrentVersion; + result.CurrentVersion = modpackInfo.Version ?? new Version("0.0.0.0"); // Check install actions if (!exists) @@ -77,7 +76,7 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf { result.Actions.AddRange(actions); result.LatestVersion = installInfos.Version; - curVersion = installInfos.Version; + result.CurrentVersion = installInfos.Version; } } @@ -96,9 +95,8 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf var checkingVersionIndex = 0; var checkingVersion = updatesOrderes.ElementAtOrDefault(checkingVersionIndex); var actionsZeroIndex = result.Actions.Count; // Ensure we insert update actions behind install actions - result.IsInstalled = true; - while (checkingVersion is not null && checkingVersion.Version > curVersion) + while (checkingVersion is not null && checkingVersion.Version > result.CurrentVersion) { var actionsToAdd = new List();