check installer correctly

This commit is contained in:
Oleksandr Bezdieniezhnykh
2025-09-23 17:35:03 +03:00
parent e501279b91
commit 2ee85d2e64
6 changed files with 11 additions and 9 deletions
+3 -3
View File
@@ -11,7 +11,7 @@ public interface IAzaionApi
{
void Login(ApiCredentials credentials);
Task<string> 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);
+1
View File
@@ -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;
}
+1 -1
View File
@@ -2,5 +2,5 @@ namespace Azaion.LoaderUI;
public class DirectoriesConfig
{
public string SuiteInstallerDirectory {get;set;} = null!;
public bool IsStage { get; set; } = false;
}
+4 -3
View File
@@ -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<Version?> 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
{
+1 -1
View File
@@ -1,6 +1,6 @@
{
"DirectoriesConfig":
{
"SuiteInstallerDirectory": null
"IsStage": false
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"DirectoriesConfig":
{
"SuiteInstallerDirectory": "suite-stage"
"IsStage": true
}
}