From 3ec94fa22d0e262d9e0ca4c11cd1ac489a47cfc6 Mon Sep 17 00:00:00 2001 From: Pilzinsel64 Date: Thu, 3 Oct 2024 10:03:40 +0200 Subject: [PATCH] add option to prefer directlinks --- ModpackUpdater.Manager/ModpackFactory.cs | 2 +- ModpackUpdater.Manager/ModpackInstaller.cs | 4 +++- ModpackUpdater/ModpackConfig.cs | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ModpackUpdater.Manager/ModpackFactory.cs b/ModpackUpdater.Manager/ModpackFactory.cs index fe702de..01e6ad1 100644 --- a/ModpackUpdater.Manager/ModpackFactory.cs +++ b/ModpackUpdater.Manager/ModpackFactory.cs @@ -66,7 +66,7 @@ public class ModpackFactory var releases = await github.Repository.Release.GetAll(repo.Id); return releases.Select(r => new KeyValuePair(r.Name ?? r.TagName, r.TagName)).ToArray(); } - catch (Exception ex) + catch (Exception) { } } diff --git a/ModpackUpdater.Manager/ModpackInstaller.cs b/ModpackUpdater.Manager/ModpackInstaller.cs index ac7eda8..8f7f094 100644 --- a/ModpackUpdater.Manager/ModpackInstaller.cs +++ b/ModpackUpdater.Manager/ModpackInstaller.cs @@ -141,7 +141,9 @@ public class ModpackInstaller(ModpackConfig updateConfig, ModpackInfo modpackInf foreach (InstallAction iaction in checkResult.Actions) { var destFilePath = Path.Combine(modpackInfo.LocaLPath, iaction.DestPath); - var sourceUrl = await factory.ResolveSourceUrl(iaction); + var sourceUrl = updateConfig.PreferDirectLinks && !string.IsNullOrWhiteSpace(iaction.SourceUrl) + ? iaction.SourceUrl + : await factory.ResolveSourceUrl(iaction); if (iaction is UpdateAction uaction) { diff --git a/ModpackUpdater/ModpackConfig.cs b/ModpackUpdater/ModpackConfig.cs index 699e732..41ef0d6 100644 --- a/ModpackUpdater/ModpackConfig.cs +++ b/ModpackUpdater/ModpackConfig.cs @@ -10,6 +10,7 @@ public class ModpackConfig public string InstallUrl { get; set; } public string UnleashApiUrl { get; set; } public string UnleashInstanceId { get; set; } + public bool PreferDirectLinks { get; set; } [JsonIgnore] public string ConfigUrl { get; set; }