some fixes

This commit is contained in:
2024-10-03 15:46:06 +02:00
parent cd929485d0
commit ee69d8af56
4 changed files with 13 additions and 12 deletions

1
.gitignore vendored
View File

@@ -348,3 +348,4 @@ MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder # Ionide (cross platform F# VS Code tools) working folder
.ionide/ .ionide/
*.json

View File

@@ -17,16 +17,16 @@ internal class Options
{ {
options = new OptionSet options = new OptionSet
{ {
{ "silent", "Do not output anything.", s => Silent = s != null }, { "silent", "Do not output anything.", s => Silent = true },
{ "h|help", "Writes the help text as output.", h => Help = h != null }, { "h|help", "Writes the help text as output.", h => Help = true },
{ "n|noui", "Install without user interface.", n => NoUi = n != null }, { "n|noui", "Install without user interface.", n => NoUi = true },
{ "p|profile=", "Sets the minecraft profile folder.", p => UpdateOptions.ProfileFolder = p }, { "p|profile=", "Sets the minecraft profile folder.", p => UpdateOptions.ProfileFolder = p },
{ "c|config=", "Sets the modpack update info url.", c => UpdateOptions.ModpackConfig = c }, { "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<Side>(s)}, { "s|side=", "Sets the installation side.\nDefault side is Client.\nAvailable: Client, Server", s => UpdateOptions.Side = Enum.Parse<Side>(s)},
{ "u|uai", "Allow an update directly after install. This only has effect if there is no existing installation.", uai => UpdateOptions.AllowUpdaterAfterInstall = uai != 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 = noupdate != null}, { "noupdate", "Skip the update check.", noupdate => UpdateOptions.NoUpdate = true},
{ "m|maintenance", "Ignores the maintenance mode.", m => UpdateOptions.IgnoreMaintenance = m != null}, { "m|maintenance", "Ignores the maintenance mode.", m => UpdateOptions.IgnoreMaintenance = true},
{ "i|nonpublic", "Include non public (currently hidden) updates.", i => UpdateOptions.IncludeNonPublic = i != null}, { "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}, { "k|key=", "An key for retriving extra files on updates.", k => UpdateOptions.ExtrasKey = k},
}; };

View File

@@ -59,6 +59,8 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf
} }
installInfos = await DownloadInstallInfos(); installInfos = await DownloadInstallInfos();
result.CurrentVersion = modpackInfo.Version ?? new Version("0.0.0.0");
var curVersion = result.CurrentVersion;
// Check install actions // Check install actions
if (!exists) if (!exists)
@@ -70,7 +72,7 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf
{ {
result.Actions.AddRange(actions); result.Actions.AddRange(actions);
result.LatestVersion = installInfos.Version; 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); var updatesOrderes = updateInfos.Updates.Where(n => n.IsPublic || options.IncludeNonPublic).OrderByDescending(n => n.Version);
result.LatestVersion = updatesOrderes.First().Version; result.LatestVersion = updatesOrderes.First().Version;
if (exists)
result.CurrentVersion = modpackInfo.Version;
result.IsInstalled = true; result.IsInstalled = true;
var checkingVersionIndex = 0; var checkingVersionIndex = 0;
var checkingVersion = updatesOrderes.ElementAtOrDefault(checkingVersionIndex); var checkingVersion = updatesOrderes.ElementAtOrDefault(checkingVersionIndex);
var actionsZeroIndex = result.Actions.Count; // Ensure we insert update actions behind install actions 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<UpdateAction>(); var actionsToAdd = new List<UpdateAction>();

View File

@@ -20,7 +20,7 @@ public class ModpackInfo
public void Save() public void Save()
{ {
File.WriteAllText(Conversions.ToString(GetFilePath(LocaLPath)), JsonConvert.SerializeObject(this)); File.WriteAllText(GetFilePath(LocaLPath), JsonConvert.SerializeObject(this));
} }
public void Save(string mcRoot) public void Save(string mcRoot)