return bool on UpdateInteractive

This commit is contained in:
Pilzinsel64
2024-09-04 10:19:16 +02:00
parent f1c99b0d51
commit a03f7047df
2 changed files with 14 additions and 10 deletions

View File

@@ -38,10 +38,10 @@ public class UpdateClientGui
// F e a t u r e s // F e a t u r e s
public async Task UpdateInteractive(Form parentForm) public async Task<bool> UpdateInteractive(Form parentForm)
{ {
this.parentForm = parentForm; this.parentForm = parentForm;
await updateClient.UpdateInteractive(); return await updateClient.UpdateInteractive();
} }
private void EndUpdating() private void EndUpdating()

View File

@@ -47,18 +47,21 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, AppChanne
// U p d a t e r o u t i n e s // U p d a t e r o u t i n e s
public async Task UpdateInteractive() public async Task<bool> UpdateInteractive()
{ {
var latestVersion = await CheckForUpdate(); var latestVersion = await CheckForUpdate();
if (HasUpdates && latestVersion is not null) if (HasUpdates && latestVersion is not null)
await UpdateInteractive(latestVersion); return await UpdateInteractive(latestVersion);
return false;
} }
public async Task UpdateInteractive(UpdatePackageInfo package) public async Task<bool> UpdateInteractive(UpdatePackageInfo package)
{ {
if (await DownloadPackageAsync(package)) if (await DownloadPackageAsync(package))
await InstallPackageAsync(package, HostApplicationPath); return await InstallPackageAsync(package, HostApplicationPath);
return false;
} }
// F e a t u r e s // F e a t u r e s
@@ -148,19 +151,19 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, AppChanne
return true; return true;
} }
public void InstallPackage(UpdatePackageInfo package, string? localInstallPath) public bool InstallPackage(UpdatePackageInfo package, string? localInstallPath)
{ {
if (string.IsNullOrWhiteSpace(localInstallPath) || !dicPackagePaths.TryGetValue(package, out var packagePath)) if (string.IsNullOrWhiteSpace(localInstallPath) || !dicPackagePaths.TryGetValue(package, out var packagePath))
{ {
RaiseStatusChanged(UpdateStatus.Failed); RaiseStatusChanged(UpdateStatus.Failed);
return; return false;
} }
// 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 false;
} }
string dataPath; string dataPath;
if (package.PackageType == PackageType.Zip) if (package.PackageType == PackageType.Zip)
@@ -203,9 +206,10 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, AppChanne
// Finish // Finish
RaiseStatusChanged(UpdateStatus.Done, UpdateStatusEvent.Default); RaiseStatusChanged(UpdateStatus.Done, UpdateStatusEvent.Default);
return true;
} }
public Task InstallPackageAsync(UpdatePackageInfo package, string? localInstallPath) public Task<bool> InstallPackageAsync(UpdatePackageInfo package, string? localInstallPath)
{ {
return Task.Run(() => InstallPackage(package, localInstallPath)); return Task.Run(() => InstallPackage(package, localInstallPath));
} }