diff --git a/ModpackUpdater.Manager/ModpackInstaller.cs b/ModpackUpdater.Manager/ModpackInstaller.cs index ed1e0d9..bbacb43 100644 --- a/ModpackUpdater.Manager/ModpackInstaller.cs +++ b/ModpackUpdater.Manager/ModpackInstaller.cs @@ -18,7 +18,7 @@ public class ModpackInstaller(ModpackConfig updateConfig, string localPath) public delegate void CheckingProgressUpdatedEventHandler(int toCheck, int processed); - private HttpClient httpClient = new(); + private readonly HttpClient httpClient = new(); ~ModpackInstaller() { @@ -37,7 +37,7 @@ public class ModpackInstaller(ModpackConfig updateConfig, string localPath) return InstallInfos.Parse(content); } - public async Task Check(bool ignoreRevmoedFiles) + public async Task Check() { var result = new UpdateCheckResult(); @@ -106,10 +106,8 @@ public class ModpackInstaller(ModpackConfig updateConfig, string localPath) { string destFilePath = Path.Combine(localPath, iaction.DestPath); - if (iaction is UpdateAction) + if (iaction is UpdateAction uaction) { - UpdateAction uaction = (UpdateAction)iaction; - switch (uaction.Type) { case UpdateActionType.Update: diff --git a/ModpackUpdater/AppConfig.cs b/ModpackUpdater/AppConfig.cs index 329d1ca..c2828ed 100644 --- a/ModpackUpdater/AppConfig.cs +++ b/ModpackUpdater/AppConfig.cs @@ -7,13 +7,11 @@ public class AppConfig public string LastMinecraftProfilePath { get; set; } public string LastConfigFilePath { get; set; } public List KeepLocalFiles { get; set; } = []; - public bool AllowRemoveLocalFiles { get; set; } public void Reset() { KeepLocalFiles.Clear(); KeepLocalFiles.Add("OptiFine_1.7.10_HD_U_E7.jar"); - AllowRemoveLocalFiles = false; } private static AppConfig instance = null; diff --git a/ModpackUpdater/Form1.cs b/ModpackUpdater/Form1.cs index b77f481..7870f9f 100644 --- a/ModpackUpdater/Form1.cs +++ b/ModpackUpdater/Form1.cs @@ -40,7 +40,8 @@ public partial class Form1 private bool CheckStatus() { - bool CheckStatusRet = default; + bool CheckStatusRet; + if (!IsMinecaftProfileLoaded() || !MinecraftProfileChecker.CheckProfile(GetMinecraftProfilePath())) { SetStatus(LangRes.StatusText_MinecraftProfileWarning, MySymbols.icons8_general_warning_sign_16px); @@ -52,9 +53,7 @@ public partial class Form1 CheckStatusRet = false; } else - { CheckStatusRet = true; - } return CheckStatusRet; } @@ -91,7 +90,7 @@ public partial class Form1 if (IsUpdateConfigLoaded()) updateConfig = (ModpackConfig)ModpackConfig.LoadFromUrl(filePath); } - catch (Exception ex) + catch { RadTextBoxControl_ModpackConfig.Text = string.Empty; } @@ -117,9 +116,9 @@ public partial class Form1 try { - lastUpdateCheckResult = await updater.Check(!AppConfig.Instance.AllowRemoveLocalFiles); + lastUpdateCheckResult = await updater.Check(); } - catch (Exception ex) + catch { SetStatus(LangRes.StatusText_ErrorWhileUpdateCheckOrUpdate, MySymbols.icons8_delete_16px); } diff --git a/ModpackUpdater/ModpackUpdater.csproj b/ModpackUpdater/ModpackUpdater.csproj index 527da51..3901c19 100644 --- a/ModpackUpdater/ModpackUpdater.csproj +++ b/ModpackUpdater/ModpackUpdater.csproj @@ -57,6 +57,7 @@ +