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>
This commit is contained in:
Copilot 2026-03-21 20:25:53 +02:00 committed by GitHub
parent b6e1f92989
commit 4a62f9c34f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 26 additions and 16 deletions

View file

@ -9,20 +9,21 @@ namespace DiscordChatExporter.Gui.Services;
public class UpdateService(SettingsService settingsService) : IDisposable public class UpdateService(SettingsService settingsService) : IDisposable
{ {
private readonly IUpdateManager? _updateManager = OperatingSystem.IsWindows() private readonly IUpdateManager? _updateManager =
? new UpdateManager( OperatingSystem.IsWindows() && StartOptions.Current.IsAutoUpdateAllowed
new GithubPackageResolver( ? new UpdateManager(
"Tyrrrz", new GithubPackageResolver(
"DiscordChatExporter", "Tyrrrz",
// Examples: "DiscordChatExporter",
// DiscordChatExporter.win-arm64.zip // Examples:
// DiscordChatExporter.win-x64.zip // DiscordChatExporter.win-arm64.zip
// DiscordChatExporter.linux-x64.zip // DiscordChatExporter.win-x64.zip
$"DiscordChatExporter.{RuntimeInformation.RuntimeIdentifier}.zip" // DiscordChatExporter.linux-x64.zip
), $"DiscordChatExporter.{RuntimeInformation.RuntimeIdentifier}.zip"
new ZipPackageExtractor() ),
) new ZipPackageExtractor()
: null; )
: null;
private Version? _updateVersion; private Version? _updateVersion;
private bool _updatePrepared; private bool _updatePrepared;

View file

@ -6,6 +6,8 @@ namespace DiscordChatExporter.Gui;
public partial class StartOptions public partial class StartOptions
{ {
public required string SettingsPath { get; init; } public required string SettingsPath { get; init; }
public required bool IsAutoUpdateAllowed { get; init; }
} }
public partial class StartOptions public partial class StartOptions
@ -20,5 +22,10 @@ public partial class StartOptions
? Path.Combine(path, "Settings.dat") ? Path.Combine(path, "Settings.dat")
: path : path
: Path.Combine(AppContext.BaseDirectory, "Settings.dat"), : Path.Combine(AppContext.BaseDirectory, "Settings.dat"),
IsAutoUpdateAllowed = !(
Environment.GetEnvironmentVariable("DISCORDCHATEXPORTER_ALLOW_AUTO_UPDATE")
is { } env
&& env.Equals("false", StringComparison.OrdinalIgnoreCase)
),
}; };
} }

View file

@ -46,6 +46,9 @@ public class SettingsViewModel : DialogViewModelBase
set => _settingsService.Language = value; set => _settingsService.Language = value;
} }
public bool IsAutoUpdateAvailable { get; } =
OperatingSystem.IsWindows() && StartOptions.Current.IsAutoUpdateAllowed;
public bool IsAutoUpdateEnabled public bool IsAutoUpdateEnabled
{ {
get => _settingsService.IsAutoUpdateEnabled; get => _settingsService.IsAutoUpdateEnabled;

View file

@ -50,8 +50,7 @@
<!-- Auto-updates --> <!-- Auto-updates -->
<DockPanel <DockPanel
Margin="16,8" Margin="16,8"
IsVisible="{OnPlatform False, IsVisible="{Binding IsAutoUpdateAvailable}"
Windows=True}"
LastChildFill="False" LastChildFill="False"
ToolTip.Tip="{Binding LocalizationManager.AutoUpdateTooltip}"> ToolTip.Tip="{Binding LocalizationManager.AutoUpdateTooltip}">
<TextBlock DockPanel.Dock="Left" Text="{Binding LocalizationManager.AutoUpdateLabel}" /> <TextBlock DockPanel.Dock="Left" Text="{Binding LocalizationManager.AutoUpdateLabel}" />