Rework updating process a bit
Test / Run tests (push) Successful in 13s

This commit is contained in:
2026-08-12 15:01:59 +02:00
parent 4e82f164c9
commit 2dee3a9ae9
8 changed files with 72 additions and 96 deletions
+10 -14
View File
@@ -1,17 +1,18 @@
using PamhagenSysCtrl.Helpers;
using System.IO;
using System.Windows;
namespace PamhagenSysCtrl.Dialogs {
public partial class UpdateDialog : Window {
private readonly UpdateInstaller Installer;
private readonly string Url;
private readonly CancellationTokenSource Cancellation = new();
public UpdateDialog(UpdateInstaller installer) {
Installer = installer;
public UpdateDialog(string version, string url, long size) {
Url = url;
InitializeComponent();
VersionText.Text = installer.Version.ToString();
SizeText.Text = Math.Ceiling(installer.Size / 1024d / 1024d).ToString("N0");
VersionText.Text = version;
SizeText.Text = Math.Ceiling(size / 1024d / 1024d).ToString("N0");
}
private void OnClosed(object? sender, EventArgs evt) {
@@ -26,20 +27,15 @@ namespace PamhagenSysCtrl.Dialogs {
try {
var progress = new Progress<double>(value => DownloadProgress.Value = value * 100);
var fileName = await UpdateService.DownloadInstallerAsync(Installer, App.TempPath, progress, Cancellation.Token);
var filename = Path.Combine(App.TempPath, $"PamhagenSysCtrl-{VersionText.Text}.msi");
await UpdateService.DownloadInstaller(Url, filename, progress, Cancellation.Token);
StatusText.Text = "Installer wird gestartet...";
UpdateService.StartInstaller(fileName);
UpdateService.StartInstaller(filename);
DialogResult = true;
} catch (OperationCanceledException) {
// Closing the dialog cancels an active download.
} catch (Exception exc) {
MessageBox.Show(
this,
$"Das Update konnte nicht installiert werden:\n\n{exc.Message}",
"Update installieren",
MessageBoxButton.OK,
MessageBoxImage.Error
);
MessageBox.Show($"Das Update konnte nicht installiert werden:\n\n{exc.Message}", "Update installieren", MessageBoxButton.OK, MessageBoxImage.Error);
Description.Visibility = Visibility.Visible;
DownloadPanel.Visibility = Visibility.Collapsed;
InstallButton.IsEnabled = true;