fail if hostapppath is null

This commit is contained in:
Pilzinsel64
2024-08-30 10:55:55 +02:00
parent dac54daf95
commit a2dc42a9a4

View File

@@ -20,10 +20,10 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, Channels
public Channels MinimumChannel { get; private set; } = (Channels)Math.Max((int)minimumChannel, (int)currentVersion.Channel); public Channels MinimumChannel { get; private set; } = (Channels)Math.Max((int)minimumChannel, (int)currentVersion.Channel);
public UpdateInfo? UpdateInfo { get; private set; } public UpdateInfo? UpdateInfo { get; private set; }
public UpdatePackageInfo? UpdatePackageInfo { get; private set; } public UpdatePackageInfo? UpdatePackageInfo { get; private set; }
public string HostApplicationPath { get; set; } = string.Empty; public string? HostApplicationPath { get; set; }
public string ApplicationName { get; set; } = string.Empty; public string? ApplicationName { get; set; }
public bool InstallAsAdmin { get; set; } = false; public bool InstallAsAdmin { get; set; }
public bool UIDarkMode { get; set; } = false; public bool UIDarkMode { get; set; }
public bool HasUpdates => UpdatePackageInfo != null; public bool HasUpdates => UpdatePackageInfo != null;
// E v e n t M e t h o d s // E v e n t M e t h o d s
@@ -150,17 +150,18 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, Channels
public void InstallPackage(UpdatePackageInfo package) public void InstallPackage(UpdatePackageInfo package)
{ {
if (string.IsNullOrWhiteSpace(HostApplicationPath) || !dicPackagePaths.TryGetValue(package, out var packagePath))
{
RaiseStatusChanged(UpdateStatus.Failed);
return;
}
// Extract Package // Extract Package
if (!RaiseStatusChanged(UpdateStatus.Extracting, UpdateStatusEvent.PreEvent, true)) if (!RaiseStatusChanged(UpdateStatus.Extracting, UpdateStatusEvent.PreEvent, true))
{ {
RaiseStatusChanged(UpdateStatus.Canceled); RaiseStatusChanged(UpdateStatus.Canceled);
return; return;
} }
if (!dicPackagePaths.TryGetValue(package, out var packagePath))
{
RaiseStatusChanged(UpdateStatus.Failed);
return;
}
string dataPath; string dataPath;
if (package.Type == PackageType.Zip) if (package.Type == PackageType.Zip)
{ {