return bool on UpdateInteractive
This commit is contained in:
@@ -38,10 +38,10 @@ public class UpdateClientGui
|
||||
|
||||
// F e a t u r e s
|
||||
|
||||
public async Task UpdateInteractive(Form parentForm)
|
||||
public async Task<bool> UpdateInteractive(Form parentForm)
|
||||
{
|
||||
this.parentForm = parentForm;
|
||||
await updateClient.UpdateInteractive();
|
||||
return await updateClient.UpdateInteractive();
|
||||
}
|
||||
|
||||
private void EndUpdating()
|
||||
|
||||
@@ -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
|
||||
|
||||
public async Task UpdateInteractive()
|
||||
public async Task<bool> UpdateInteractive()
|
||||
{
|
||||
var latestVersion = await CheckForUpdate();
|
||||
|
||||
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))
|
||||
await InstallPackageAsync(package, HostApplicationPath);
|
||||
return await InstallPackageAsync(package, HostApplicationPath);
|
||||
return false;
|
||||
}
|
||||
|
||||
// F e a t u r e s
|
||||
@@ -148,19 +151,19 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, AppChanne
|
||||
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))
|
||||
{
|
||||
RaiseStatusChanged(UpdateStatus.Failed);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Extract Package
|
||||
if (RaiseStatusChanged(UpdateStatus.Extracting, UpdateStatusEvent.PreEvent, true))
|
||||
{
|
||||
RaiseStatusChanged(UpdateStatus.Canceled);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
string dataPath;
|
||||
if (package.PackageType == PackageType.Zip)
|
||||
@@ -203,9 +206,10 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, AppChanne
|
||||
|
||||
// Finish
|
||||
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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user