diff --git a/.gitignore b/.gitignore index 98ee568..3fa6955 100644 --- a/.gitignore +++ b/.gitignore @@ -348,3 +348,4 @@ MigrationBackup/ # Ionide (cross platform F# VS Code tools) working folder .ionide/ +*.json diff --git a/ModpackUpdater.Apps.Client/Options.cs b/ModpackUpdater.Apps.Client/Options.cs index 40d255b..74289f7 100644 --- a/ModpackUpdater.Apps.Client/Options.cs +++ b/ModpackUpdater.Apps.Client/Options.cs @@ -17,16 +17,16 @@ internal class Options { options = new OptionSet { - { "silent", "Do not output anything.", s => Silent = s != null }, - { "h|help", "Writes the help text as output.", h => Help = h != null }, - { "n|noui", "Install without user interface.", n => NoUi = n != null }, + { "silent", "Do not output anything.", s => Silent = true }, + { "h|help", "Writes the help text as output.", h => Help = true }, + { "n|noui", "Install without user interface.", n => NoUi = true }, { "p|profile=", "Sets the minecraft profile folder.", p => UpdateOptions.ProfileFolder = p }, { "c|config=", "Sets the modpack update info url.", c => UpdateOptions.ModpackConfig = c }, { "s|side=", "Sets the installation side.\nDefault side is Client.\nAvailable: Client, Server", s => UpdateOptions.Side = Enum.Parse(s)}, - { "u|uai", "Allow an update directly after install. This only has effect if there is no existing installation.", uai => UpdateOptions.AllowUpdaterAfterInstall = uai != null}, - { "noupdate", "Skip the update check.", noupdate => UpdateOptions.NoUpdate = noupdate != null}, - { "m|maintenance", "Ignores the maintenance mode.", m => UpdateOptions.IgnoreMaintenance = m != null}, - { "i|nonpublic", "Include non public (currently hidden) updates.", i => UpdateOptions.IncludeNonPublic = i != null}, + { "u|uai", "Disallow an update directly after install. This only has effect if there is no existing installation.", uai => UpdateOptions.AllowUpdaterAfterInstall = false}, + { "noupdate", "Skip the update check.", noupdate => UpdateOptions.NoUpdate = true}, + { "m|maintenance", "Ignores the maintenance mode.", m => UpdateOptions.IgnoreMaintenance = true}, + { "i|nonpublic", "Include non public (currently hidden) updates.", i => UpdateOptions.IncludeNonPublic = true}, { "k|key=", "An key for retriving extra files on updates.", k => UpdateOptions.ExtrasKey = k}, }; diff --git a/ModpackUpdater.Manager/ModpackInstaller.cs b/ModpackUpdater.Manager/ModpackInstaller.cs index 8f7f094..598d56c 100644 --- a/ModpackUpdater.Manager/ModpackInstaller.cs +++ b/ModpackUpdater.Manager/ModpackInstaller.cs @@ -59,6 +59,8 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf } installInfos = await DownloadInstallInfos(); + result.CurrentVersion = modpackInfo.Version ?? new Version("0.0.0.0"); + var curVersion = result.CurrentVersion; // Check install actions if (!exists) @@ -70,7 +72,7 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf { result.Actions.AddRange(actions); result.LatestVersion = installInfos.Version; - result.CurrentVersion = installInfos.Version; + curVersion = installInfos.Version; } } @@ -87,15 +89,13 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf { var updatesOrderes = updateInfos.Updates.Where(n => n.IsPublic || options.IncludeNonPublic).OrderByDescending(n => n.Version); result.LatestVersion = updatesOrderes.First().Version; - if (exists) - result.CurrentVersion = modpackInfo.Version; result.IsInstalled = true; var checkingVersionIndex = 0; var checkingVersion = updatesOrderes.ElementAtOrDefault(checkingVersionIndex); var actionsZeroIndex = result.Actions.Count; // Ensure we insert update actions behind install actions - while (checkingVersion is not null && checkingVersion.Version > result.CurrentVersion) + while (checkingVersion is not null && checkingVersion.Version > curVersion) { var actionsToAdd = new List(); diff --git a/ModpackUpdater/ModpackInfo.cs b/ModpackUpdater/ModpackInfo.cs index c177841..de0c903 100644 --- a/ModpackUpdater/ModpackInfo.cs +++ b/ModpackUpdater/ModpackInfo.cs @@ -20,7 +20,7 @@ public class ModpackInfo public void Save() { - File.WriteAllText(Conversions.ToString(GetFilePath(LocaLPath)), JsonConvert.SerializeObject(this)); + File.WriteAllText(GetFilePath(LocaLPath), JsonConvert.SerializeObject(this)); } public void Save(string mcRoot)