From 2ee85d2e6493c6d4369032ef3077eeccfc2f2365 Mon Sep 17 00:00:00 2001 From: Oleksandr Bezdieniezhnykh Date: Tue, 23 Sep 2025 17:35:03 +0300 Subject: [PATCH] check installer correctly --- Azaion.LoaderUI/AzaionApi.cs | 6 +++--- Azaion.LoaderUI/ConstantsLoader.cs | 1 + Azaion.LoaderUI/LoaderConfig.cs | 2 +- Azaion.LoaderUI/Login.xaml.cs | 7 ++++--- Azaion.LoaderUI/loaderconfig.prod.json | 2 +- Azaion.LoaderUI/loaderconfig.stage.json | 2 +- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Azaion.LoaderUI/AzaionApi.cs b/Azaion.LoaderUI/AzaionApi.cs index effc478..5e59249 100644 --- a/Azaion.LoaderUI/AzaionApi.cs +++ b/Azaion.LoaderUI/AzaionApi.cs @@ -11,7 +11,7 @@ public interface IAzaionApi { void Login(ApiCredentials credentials); Task GetLastInstallerName(string folder); - Task<(string name, Stream stream)> DownloadInstaller(string folder); + Task<(string name, Stream stream)> DownloadInstaller(bool isStage = false); } public class AzaionApi(HttpClient client) : IAzaionApi @@ -31,9 +31,9 @@ public class AzaionApi(HttpClient client) : IAzaionApi return res?.FirstOrDefault() ?? ""; } - public async Task<(string name, Stream stream)> DownloadInstaller(string folder) + public async Task<(string name, Stream stream)> DownloadInstaller(bool isStage = false) { - var response = await Send(new HttpRequestMessage(HttpMethod.Get, $"resources/get-installer/{folder}")); + var response = await Send(new HttpRequestMessage(HttpMethod.Get, $"resources/get-installer/{isStage}")); var fileStream = await response.Content.ReadAsStreamAsync(); var fileName = response.Content.Headers.ContentDisposition?.FileName?.Trim('"') ?? "installer.exe"; return (fileName, fileStream); diff --git a/Azaion.LoaderUI/ConstantsLoader.cs b/Azaion.LoaderUI/ConstantsLoader.cs index 7f38ef6..7fa9243 100644 --- a/Azaion.LoaderUI/ConstantsLoader.cs +++ b/Azaion.LoaderUI/ConstantsLoader.cs @@ -3,5 +3,6 @@ namespace Azaion.LoaderUI; public static class ConstantsLoader { public const string SUITE_FOLDER = "suite"; + public const string SUITE_STAGE_FOLDER = "suite-stage"; public const int EXTERNAL_LOADER_PORT = 5020; } \ No newline at end of file diff --git a/Azaion.LoaderUI/LoaderConfig.cs b/Azaion.LoaderUI/LoaderConfig.cs index 169e376..9ab7153 100644 --- a/Azaion.LoaderUI/LoaderConfig.cs +++ b/Azaion.LoaderUI/LoaderConfig.cs @@ -2,5 +2,5 @@ namespace Azaion.LoaderUI; public class DirectoriesConfig { - public string SuiteInstallerDirectory {get;set;} = null!; + public bool IsStage { get; set; } = false; } \ No newline at end of file diff --git a/Azaion.LoaderUI/Login.xaml.cs b/Azaion.LoaderUI/Login.xaml.cs index dfcb67d..47a2b42 100644 --- a/Azaion.LoaderUI/Login.xaml.cs +++ b/Azaion.LoaderUI/Login.xaml.cs @@ -63,7 +63,7 @@ public partial class Login if (installerVersion > localVersion) { TbStatus.Text = $"Updating from {localVersion} to {installerVersion}..."; - var (installerName, stream) = await _azaionApi.DownloadInstaller(_dirConfig?.SuiteInstallerDirectory ?? ""); + var (installerName, stream) = await _azaionApi.DownloadInstaller(_dirConfig?.IsStage ?? false); var localFileStream = new FileStream(installerName, FileMode.Create, FileAccess.Write); await stream.CopyToAsync(localFileStream); localFileStream.Close(); @@ -164,9 +164,10 @@ public partial class Login private async Task GetInstallerVer() { TbStatus.Text = "Checking for the newer version..."; - var installerDir = string.IsNullOrWhiteSpace(_dirConfig?.SuiteInstallerDirectory) + var installerDir = _dirConfig?.IsStage ?? false ? ConstantsLoader.SUITE_FOLDER - : _dirConfig.SuiteInstallerDirectory; + : ConstantsLoader.SUITE_STAGE_FOLDER; + var installerName = await _azaionApi.GetLastInstallerName(installerDir); try { diff --git a/Azaion.LoaderUI/loaderconfig.prod.json b/Azaion.LoaderUI/loaderconfig.prod.json index 4b65763..749da62 100644 --- a/Azaion.LoaderUI/loaderconfig.prod.json +++ b/Azaion.LoaderUI/loaderconfig.prod.json @@ -1,6 +1,6 @@ { "DirectoriesConfig": { - "SuiteInstallerDirectory": null + "IsStage": false } } \ No newline at end of file diff --git a/Azaion.LoaderUI/loaderconfig.stage.json b/Azaion.LoaderUI/loaderconfig.stage.json index 01edb38..c6c9801 100644 --- a/Azaion.LoaderUI/loaderconfig.stage.json +++ b/Azaion.LoaderUI/loaderconfig.stage.json @@ -1,6 +1,6 @@ { "DirectoriesConfig": { - "SuiteInstallerDirectory": "suite-stage" + "IsStage": true } } \ No newline at end of file