update deps & enable console logging

This commit is contained in:
2024-12-05 07:06:06 +01:00
parent a83d109f24
commit 3e1ab72162
6 changed files with 39 additions and 22 deletions

View File

@@ -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();
@@ -153,7 +156,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 +202,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,7 +221,7 @@ 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));
@@ -257,7 +261,13 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf
}
catch (HttpRequestException ex)
{
throw;
Log.Error("Could not download file: " + sourceUrl, ex);
return false;
}
catch (Exception ex)
{
Log.Error("Could not install file: " + sourceUrl, ex);
return false;
}
}
@@ -268,5 +278,7 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf
var zipSrc = Path.Combine(cachedZipInfo.ExtractedZipPath, zipPath);
Extensions.CopyDirectory(zipSrc, destFilePath, true);
}
return true;
}
}

View File

@@ -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>