From 4a62f9c34f1acb7ae846449ac7bfce47e2de651c Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Sat, 21 Mar 2026 20:25:53 +0200 Subject: [PATCH] Add `DISCORDCHATEXPORTER_ALLOW_AUTO_UPDATE` env var to suppress auto-update in GUI (#1514) * Add DISCORDCHATEXPORTER_DISABLE_UPDATE env var to disable auto-update in GUI Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> Agent-Logs-Url: https://github.com/Tyrrrz/DiscordChatExporter/sessions/158dba86-9958-4f57-ab22-174e0606b42f * Rename IsAutoUpdateDisabled to IsAutoUpdateAllowed and env var to DISCORDCHATEXPORTER_ALLOW_AUTO_UPDATE Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> Agent-Logs-Url: https://github.com/Tyrrrz/DiscordChatExporter/sessions/aa3944a4-e542-4770-8d17-2acb2c958ce9 * Refine IsAutoUpdateAllowed: group in (), invert, rename v to env, only accept false Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> Agent-Logs-Url: https://github.com/Tyrrrz/DiscordChatExporter/sessions/1467eee2-3069-4f0b-abdf-b1dc65e00a9a * Fix CSharpier formatting: move is { } env to indented new line Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> Agent-Logs-Url: https://github.com/Tyrrrz/DiscordChatExporter/sessions/7933cfe4-ecad-4697-8b9c-ee3991aa147e --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> --- .../Services/UpdateService.cs | 29 ++++++++++--------- DiscordChatExporter.Gui/StartOptions.cs | 7 +++++ .../ViewModels/Dialogs/SettingsViewModel.cs | 3 ++ .../Views/Dialogs/SettingsView.axaml | 3 +- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/DiscordChatExporter.Gui/Services/UpdateService.cs b/DiscordChatExporter.Gui/Services/UpdateService.cs index 2fc367da..b249bb16 100644 --- a/DiscordChatExporter.Gui/Services/UpdateService.cs +++ b/DiscordChatExporter.Gui/Services/UpdateService.cs @@ -9,20 +9,21 @@ namespace DiscordChatExporter.Gui.Services; public class UpdateService(SettingsService settingsService) : IDisposable { - private readonly IUpdateManager? _updateManager = OperatingSystem.IsWindows() - ? new UpdateManager( - new GithubPackageResolver( - "Tyrrrz", - "DiscordChatExporter", - // Examples: - // DiscordChatExporter.win-arm64.zip - // DiscordChatExporter.win-x64.zip - // DiscordChatExporter.linux-x64.zip - $"DiscordChatExporter.{RuntimeInformation.RuntimeIdentifier}.zip" - ), - new ZipPackageExtractor() - ) - : null; + private readonly IUpdateManager? _updateManager = + OperatingSystem.IsWindows() && StartOptions.Current.IsAutoUpdateAllowed + ? new UpdateManager( + new GithubPackageResolver( + "Tyrrrz", + "DiscordChatExporter", + // Examples: + // DiscordChatExporter.win-arm64.zip + // DiscordChatExporter.win-x64.zip + // DiscordChatExporter.linux-x64.zip + $"DiscordChatExporter.{RuntimeInformation.RuntimeIdentifier}.zip" + ), + new ZipPackageExtractor() + ) + : null; private Version? _updateVersion; private bool _updatePrepared; diff --git a/DiscordChatExporter.Gui/StartOptions.cs b/DiscordChatExporter.Gui/StartOptions.cs index f29a04ea..d17752a8 100644 --- a/DiscordChatExporter.Gui/StartOptions.cs +++ b/DiscordChatExporter.Gui/StartOptions.cs @@ -6,6 +6,8 @@ namespace DiscordChatExporter.Gui; public partial class StartOptions { public required string SettingsPath { get; init; } + + public required bool IsAutoUpdateAllowed { get; init; } } public partial class StartOptions @@ -20,5 +22,10 @@ public partial class StartOptions ? Path.Combine(path, "Settings.dat") : path : Path.Combine(AppContext.BaseDirectory, "Settings.dat"), + IsAutoUpdateAllowed = !( + Environment.GetEnvironmentVariable("DISCORDCHATEXPORTER_ALLOW_AUTO_UPDATE") + is { } env + && env.Equals("false", StringComparison.OrdinalIgnoreCase) + ), }; } diff --git a/DiscordChatExporter.Gui/ViewModels/Dialogs/SettingsViewModel.cs b/DiscordChatExporter.Gui/ViewModels/Dialogs/SettingsViewModel.cs index 544f4ba1..143246ca 100644 --- a/DiscordChatExporter.Gui/ViewModels/Dialogs/SettingsViewModel.cs +++ b/DiscordChatExporter.Gui/ViewModels/Dialogs/SettingsViewModel.cs @@ -46,6 +46,9 @@ public class SettingsViewModel : DialogViewModelBase set => _settingsService.Language = value; } + public bool IsAutoUpdateAvailable { get; } = + OperatingSystem.IsWindows() && StartOptions.Current.IsAutoUpdateAllowed; + public bool IsAutoUpdateEnabled { get => _settingsService.IsAutoUpdateEnabled; diff --git a/DiscordChatExporter.Gui/Views/Dialogs/SettingsView.axaml b/DiscordChatExporter.Gui/Views/Dialogs/SettingsView.axaml index 03bbb3ac..f4e3c7a3 100644 --- a/DiscordChatExporter.Gui/Views/Dialogs/SettingsView.axaml +++ b/DiscordChatExporter.Gui/Views/Dialogs/SettingsView.axaml @@ -50,8 +50,7 @@