some more bugfixes & cleanup

This commit is contained in:
2024-06-22 13:39:17 +02:00
parent 4b78ce1b6f
commit 11e9290fc8
5 changed files with 150 additions and 124 deletions

View File

@@ -2,7 +2,6 @@
namespace ModpackUpdater.Manager;
public static class Extensions
{
public static bool IsSide(this Side @this, Side side)
@@ -30,7 +29,7 @@ public static class Extensions
foreach (FileInfo @file in dir.GetFiles())
{
string targetFilePath = Path.Combine(destinationDir, @file.Name);
@file.CopyTo(targetFilePath);
@file.CopyTo(targetFilePath, true);
}
// If recursive and copying subdirectories, recursively call this method
@@ -43,5 +42,4 @@ public static class Extensions
}
}
}
}

View File

@@ -42,6 +42,7 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf
InstallInfos installInfos = null;
UpdateInfos updateInfos = null;
var result = new UpdateCheckResult();
var exists = modpackInfo.Exists;
if (updateConfig.Maintenance && !options.IgnoreMaintenance)
{
@@ -55,7 +56,7 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf
return result;
}
if (!modpackInfo.Exists)
if (!exists)
{
installInfos = await DownloadInstallInfos();
@@ -66,6 +67,7 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf
{
result.Actions.AddRange(installInfos.Actions);
result.LatestVersion = installInfos.Version;
result.CurrentVersion = installInfos.Version;
}
}
@@ -73,7 +75,7 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf
result.HasError = true;
}
if (options.AllowUpdaterAfterInstall)
if (exists || options.AllowUpdaterAfterInstall)
{
updateInfos = await DownloadUpdateInfos();
@@ -81,11 +83,13 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf
{
var updatesOrderes = updateInfos.Updates.OrderByDescending(n => n.Version);
result.LatestVersion = updatesOrderes.First().Version;
result.CurrentVersion = modpackInfo.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)
{
@@ -97,7 +101,7 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf
actionsToAdd.Add(action);
}
result.Actions.InsertRange(0, actionsToAdd);
result.Actions.InsertRange(actionsZeroIndex, actionsToAdd);
checkingVersionIndex += 1;
checkingVersion = updatesOrderes.ElementAtOrDefault(checkingVersionIndex);