rework autoupdate to script only

zoom fix
This commit is contained in:
Alex Bezdieniezhnykh
2025-07-06 23:22:21 +03:00
parent 75d3a2412f
commit 6229ca8a03
12 changed files with 179 additions and 80 deletions
+22 -28
View File
@@ -6,6 +6,7 @@ using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using Azaion.Common;
using MessagePack;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
@@ -57,22 +58,34 @@ public partial class Login
TbStatus.Foreground = Brushes.Black;
var installerVersion = await GetInstallerVer();
var localVersion = GetLocalVer();
var credsEncrypted = Security.Encrypt(creds);
if (installerVersion > localVersion)
{
TbStatus.Text = $"Updating from {localVersion} to {installerVersion}...";
await DownloadAndRunInstaller();
TbStatus.Text = $"Installed {installerVersion}!";
var (installerName, stream) = await _azaionApi.DownloadInstaller(_dirConfig?.SuiteInstallerDirectory ?? "");
var localFileStream = new FileStream(installerName, FileMode.Create, FileAccess.Write);
await stream.CopyToAsync(localFileStream);
localFileStream.Close();
stream.Close();
Process.Start(new ProcessStartInfo
{
FileName = "cmd.exe",
Arguments = $"/c updater.cmd {Process.GetCurrentProcess().Id} {installerName} {Constants.AZAION_SUITE_EXE} \"{credsEncrypted}\""
});
}
else
{
TbStatus.Text = "Your version is up to date!";
Process.Start(Constants.AZAION_SUITE_EXE, $"-e {creds.Email} -p {creds.Password}");
await Task.Delay(800);
TbStatus.Text = "Loading...";
while (!Process.GetProcessesByName(Constants.INFERENCE_EXE).Any())
await Task.Delay(500);
await Task.Delay(1500);
Process.Start(Constants.AZAION_SUITE_EXE, $"-c {credsEncrypted}");
await Task.Delay(800);
TbStatus.Text = "Loading...";
while (!Process.GetProcessesByName(Constants.INFERENCE_EXE).Any())
await Task.Delay(500);
await Task.Delay(1500);
}
Close();
}
catch (Exception exception)
@@ -146,26 +159,7 @@ public partial class Login
throw;
}
}
private async Task DownloadAndRunInstaller()
{
var (installerName, stream) = await _azaionApi.DownloadInstaller(_dirConfig?.SuiteInstallerDirectory ?? "");
var localFileStream = new FileStream(installerName, FileMode.Create, FileAccess.Write);
await stream.CopyToAsync(localFileStream);
localFileStream.Close();
stream.Close();
var processInfo = new ProcessStartInfo(installerName)
{
UseShellExecute = true,
Arguments = "/VERYSILENT"
};
var process = Process.Start(processInfo);
await process!.WaitForExitAsync();
File.Delete(installerName);
}
private async Task<Version> GetInstallerVer()
{
TbStatus.Text = "Checking for the newer version...";