diff --git a/ModpackUpdater.Apps.Client.Gui/AppUpdater.cs b/ModpackUpdater.Apps.Client.Gui/AppUpdater.cs index d67a431..ba988aa 100644 --- a/ModpackUpdater.Apps.Client.Gui/AppUpdater.cs +++ b/ModpackUpdater.Apps.Client.Gui/AppUpdater.cs @@ -54,7 +54,7 @@ public class AppUpdater(string updateUrl) } // Download the new file - using (var tempFileStream = new FileStream(tempFileName, FileMode.Create, FileAccess.ReadWrite)) + await using (var tempFileStream = new FileStream(tempFileName, FileMode.Create, FileAccess.ReadWrite)) { Stream? downloadStream = null; try @@ -68,7 +68,8 @@ public class AppUpdater(string updateUrl) } finally { - downloadStream?.Dispose(); + if (downloadStream != null) + await downloadStream.DisposeAsync(); } } diff --git a/ModpackUpdater.Apps.Client.Gui/MainForm.axaml.cs b/ModpackUpdater.Apps.Client.Gui/MainForm.axaml.cs index a7f0a2d..d7ccf6e 100644 --- a/ModpackUpdater.Apps.Client.Gui/MainForm.axaml.cs +++ b/ModpackUpdater.Apps.Client.Gui/MainForm.axaml.cs @@ -62,9 +62,9 @@ public partial class MainForm : Window { loadingData = true; - TextBoxMinecraftProfileFolder.Text = modpackInfo?.LocaLPath ?? AppConfig.Instance.LastMinecraftProfilePath ?? TextBoxMinecraftProfileFolder.Text; - TextBoxModpackConfig.Text = modpackInfo?.ConfigUrl ?? TextBoxModpackConfig.Text; - TextBoxInstallKey.Text = modpackInfo?.ExtrasKey ?? TextBoxInstallKey.Text; + TextBoxMinecraftProfileFolder.Text = modpackInfo.LocaLPath ?? AppConfig.Instance.LastMinecraftProfilePath ?? TextBoxMinecraftProfileFolder.Text; + TextBoxModpackConfig.Text = modpackInfo.ConfigUrl ?? TextBoxModpackConfig.Text; + TextBoxInstallKey.Text = modpackInfo.ExtrasKey ?? TextBoxInstallKey.Text; loadingData = false; } @@ -186,9 +186,6 @@ public partial class MainForm : Window if (Debugger.IsAttached) throw; } - finally - { - } } // Error while update check @@ -263,7 +260,7 @@ public partial class MainForm : Window private async void MainForm_Loaded(object? sender, RoutedEventArgs e) { - var updater = new AppUpdater(Program.UPDATE_URL); + var updater = new AppUpdater(Program.UpdateUrl); if (await updater.Check() && await MessageBoxManager.GetMessageBoxStandard(MsgBoxLangRes.UpdateAvailable_Title, MsgBoxLangRes.UpdateAvailable, ButtonEnum.YesNo).ShowWindowDialogAsync(this) == ButtonResult.Ok) { SetStatus(GeneralLangRes.DownloadProgramUpdate, Symbols.Fluent.GetImageSource(SymbolsFluent.software_installer)); diff --git a/ModpackUpdater.Apps.Client.Gui/Program.cs b/ModpackUpdater.Apps.Client.Gui/Program.cs index 48b4869..6a01a31 100644 --- a/ModpackUpdater.Apps.Client.Gui/Program.cs +++ b/ModpackUpdater.Apps.Client.Gui/Program.cs @@ -7,13 +7,12 @@ namespace ModpackUpdater.Apps.Client.Gui; public static class Program { - public const string UPDATE_URL = "https://git.pilzinsel64.de/litw-refined/minecraft-modpack-updater/-/snippets/3/raw/main/updates.json"; + public const string UpdateUrl = "https://git.pilzinsel64.de/litw-refined/minecraft-modpack-updater/-/snippets/3/raw/main/updates.json"; private static readonly SettingsManager settingsManager; - private static readonly ILogger log = new ConsoleLogger(); public static ISettings Settings => settingsManager.Instance; - public static ILogger Log => log; + public static ILogger Log { get; } = new ConsoleLogger(); static Program() { @@ -37,13 +36,13 @@ public static class Program private static string GetSettingsPath(int? settingsVersion = 3) { - const string AppDataDirectoryName = "MinecraftModpackUpdater"; + const string appDataDirectoryName = "MinecraftModpackUpdater"; var fileNamePostfix = settingsVersion == null ? string.Empty : $"V{settingsVersion}"; - var SettingsFileName = $"Settings{fileNamePostfix}.json"; + var settingsFileName = $"Settings{fileNamePostfix}.json"; - var settingsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), AppDataDirectoryName); + var settingsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), appDataDirectoryName); Directory.CreateDirectory(settingsPath); - settingsPath = Path.Combine(settingsPath, SettingsFileName); + settingsPath = Path.Combine(settingsPath, settingsFileName); return settingsPath; }