Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3b79335e85 | |||
| 3e1ab72162 | |||
| a83d109f24 | |||
| e50d5f4874 | |||
| 72b765e6fd |
@@ -90,7 +90,7 @@ public partial class Form1
|
||||
radTextBox_InstallKey.Text = modpackInfo.ExtrasKey;
|
||||
}
|
||||
else
|
||||
radTextBox_InstallKey.Text = radTextBox_InstallKey.Text;
|
||||
modpackInfo.ExtrasKey = radTextBox_InstallKey.Text;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
@@ -39,11 +39,11 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Mono.Options" Version="6.12.0.148" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Pilz.Configuration" Version="3.1.3" />
|
||||
<PackageReference Include="Pilz.Configuration" Version="3.2.0" />
|
||||
<PackageReference Include="Pilz.Cryptography" Version="2.1.1" />
|
||||
<PackageReference Include="Pilz.IO" Version="2.1.0" />
|
||||
<PackageReference Include="Pilz.UI" Version="2.3.10" />
|
||||
<PackageReference Include="Pilz.UI.Telerik" Version="2.7.4" />
|
||||
<PackageReference Include="Pilz.UI" Version="2.3.14" />
|
||||
<PackageReference Include="Pilz.UI.Telerik" Version="2.8.1" />
|
||||
<PackageReference Include="Pilz.Win32" Version="2.1.0" />
|
||||
<PackageReference Include="UI.for.WinForms.Common" Version="2024.3.806" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
using ModpackUpdater.Manager;
|
||||
using Castle.Core.Logging;
|
||||
using ModpackUpdater.Manager;
|
||||
using Newtonsoft.Json;
|
||||
using Pilz;
|
||||
using Pilz.Configuration;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyAppVersion("1.6.1.0")]
|
||||
[assembly: AssemblyAppVersion("1.6.3.0")]
|
||||
|
||||
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();
|
||||
|
||||
@@ -97,20 +101,23 @@ public static class Program
|
||||
updateOptions.IncludeExtras = features.IsEnabled(ModpackFeatures.FeatureAllowExtas, new AllowExtrasFeatureContext(info));
|
||||
|
||||
// Check for update
|
||||
var installer = new ModpackInstaller(config, info);
|
||||
var installer = new ModpackInstaller(config, info)
|
||||
{
|
||||
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)
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NGitLab" Version="6.55.0" />
|
||||
<PackageReference Include="Pilz.Configuration" Version="3.1.3" />
|
||||
<PackageReference Include="Pilz.Plugins.Advanced" Version="2.10.1" />
|
||||
<PackageReference Include="Pilz.Plugins.Advanced.UI" Version="1.7.0" />
|
||||
<PackageReference Include="Pilz.Plugins.Advanced.UI.Telerik" Version="1.7.0" />
|
||||
<PackageReference Include="Pilz.UI" Version="2.3.10" />
|
||||
<PackageReference Include="Pilz.UI.Telerik" Version="2.7.4" />
|
||||
<PackageReference Include="NGitLab" Version="6.59.0" />
|
||||
<PackageReference Include="Pilz.Configuration" Version="3.2.0" />
|
||||
<PackageReference Include="Pilz.Plugins.Advanced" Version="2.10.2" />
|
||||
<PackageReference Include="Pilz.Plugins.Advanced.UI" Version="1.8.3" />
|
||||
<PackageReference Include="Pilz.Plugins.Advanced.UI.Telerik" Version="1.7.2" />
|
||||
<PackageReference Include="Pilz.UI" Version="2.3.14" />
|
||||
<PackageReference Include="Pilz.UI.Telerik" Version="2.8.1" />
|
||||
<PackageReference Include="UI.for.WinForms.Common" Version="2024.3.806" />
|
||||
<PackageReference Include="UI.for.WinForms.GridView" Version="2024.3.806" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Pilz.UI" Version="2.3.10" />
|
||||
<PackageReference Include="Pilz.UI.Telerik" Version="2.7.4" />
|
||||
<PackageReference Include="Pilz.UI" Version="2.3.14" />
|
||||
<PackageReference Include="Pilz.UI.Telerik" Version="2.8.1" />
|
||||
<PackageReference Include="UI.for.WinForms.Common" Version="2024.3.806" />
|
||||
<PackageReference Include="UI.for.WinForms.Themes" Version="2024.3.806" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using Castle.Core.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using System.IO.Compression;
|
||||
using FileMode = System.IO.FileMode;
|
||||
|
||||
@@ -19,6 +20,8 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf
|
||||
|
||||
public delegate void CheckingProgressUpdatedEventHandler(int toCheck, int processed);
|
||||
|
||||
public ILogger Log { get; set; } = NullLogger.Instance;
|
||||
|
||||
private readonly HttpClient http = new();
|
||||
private readonly ModpackFactory factory = new();
|
||||
|
||||
@@ -60,7 +63,6 @@ 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)
|
||||
@@ -74,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,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<UpdateAction>();
|
||||
|
||||
@@ -153,7 +154,8 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf
|
||||
switch (uaction.Type)
|
||||
{
|
||||
case UpdateActionType.Update:
|
||||
await InstallFile(destFilePath, sourceUrl, uaction.IsZip, uaction.ZipPath, localZipCache);
|
||||
if (!await InstallFile(destFilePath, sourceUrl, uaction.IsZip, uaction.ZipPath, localZipCache))
|
||||
return false;
|
||||
break;
|
||||
case UpdateActionType.Delete:
|
||||
{
|
||||
@@ -198,8 +200,8 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
await InstallFile(destFilePath, sourceUrl, iaction.IsZip, iaction.ZipPath, localZipCache);
|
||||
else if (!await InstallFile(destFilePath, sourceUrl, iaction.IsZip, iaction.ZipPath, localZipCache))
|
||||
return false;
|
||||
|
||||
processed += 1;
|
||||
InstallProgessUpdated?.Invoke(checkResult, processed);
|
||||
@@ -217,11 +219,13 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf
|
||||
return true;
|
||||
}
|
||||
|
||||
private async Task InstallFile(string destFilePath, string sourceUrl, bool isZip, string zipPath, List<LocalZipCacheEntry> localZipCache)
|
||||
private async Task<bool> InstallFile(string destFilePath, string sourceUrl, bool isZip, string zipPath, List<LocalZipCacheEntry> localZipCache)
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(destFilePath));
|
||||
|
||||
if (!isZip || localZipCache.FirstOrDefault(n => n.DownloadUrl == sourceUrl) is not LocalZipCacheEntry cachedZipInfo)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Download
|
||||
var fsDestinationPath = isZip ? Path.Combine(Path.GetTempPath(), $"mc_update_file_{DateTime.Now.ToBinary()}.zip") : destFilePath;
|
||||
@@ -253,6 +257,17 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf
|
||||
else
|
||||
cachedZipInfo = null;
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
Log.Error("Could not download file: " + sourceUrl, ex);
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error("Could not install file: " + sourceUrl, ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle zip file content
|
||||
if (cachedZipInfo != null)
|
||||
@@ -261,5 +276,7 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf
|
||||
var zipSrc = Path.Combine(cachedZipInfo.ExtractedZipPath, zipPath);
|
||||
Extensions.CopyDirectory(zipSrc, destFilePath, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -7,11 +7,12 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Castle.Core" Version="5.1.1" />
|
||||
<PackageReference Include="CurseForge.APIClient" Version="3.0.0" />
|
||||
<PackageReference Include="Modrinth.Net" Version="3.4.5" />
|
||||
<PackageReference Include="Octokit" Version="13.0.1" />
|
||||
<PackageReference Include="System.IO.Compression.ZipFile" Version="4.3.0" />
|
||||
<PackageReference Include="Unleash.Client" Version="4.1.12" />
|
||||
<PackageReference Include="Unleash.Client" Version="5.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user