From 8fae2a2c9da2c5d46775fffae3cbbbcabf61997f Mon Sep 17 00:00:00 2001 From: Pilzinsel64 Date: Sun, 13 Oct 2024 11:54:36 +0200 Subject: [PATCH] improvements for first installation --- ModpackUpdater.Manager/ModpackInstaller.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ModpackUpdater.Manager/ModpackInstaller.cs b/ModpackUpdater.Manager/ModpackInstaller.cs index 598d56c..f2312ec 100644 --- a/ModpackUpdater.Manager/ModpackInstaller.cs +++ b/ModpackUpdater.Manager/ModpackInstaller.cs @@ -65,6 +65,8 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf // Check install actions if (!exists) { + result.IsInstalled = false; + if (installInfos is not null && installInfos.IsPublic && installInfos.Actions.Count != 0) { var actions = installInfos.Actions.Where(n => n.Side.IsSide(options.Side) && (!n.IsExtra || options.IncludeExtras)); @@ -81,19 +83,17 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf } // Check update actions - if (exists || options.AllowUpdaterAfterInstall) + if (!result.HasError && (exists || options.AllowUpdaterAfterInstall)) { updateInfos = await DownloadUpdateInfos(); if (updateInfos is not null && updateInfos.Updates.Count != 0) { var updatesOrderes = updateInfos.Updates.Where(n => n.IsPublic || options.IncludeNonPublic).OrderByDescending(n => n.Version); - result.LatestVersion = updatesOrderes.First().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 + result.IsInstalled = true; while (checkingVersion is not null && checkingVersion.Version > curVersion) { @@ -111,6 +111,9 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf result.Actions.InsertRange(actionsZeroIndex, actionsToAdd); + if (result.LatestVersion < checkingVersion.Version) + result.LatestVersion = checkingVersion.Version; + checkingVersionIndex += 1; checkingVersion = updatesOrderes.ElementAtOrDefault(checkingVersionIndex); }