mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 08:36:29 +00:00
check installer correctly
This commit is contained in:
@@ -11,7 +11,7 @@ public interface IAzaionApi
|
|||||||
{
|
{
|
||||||
void Login(ApiCredentials credentials);
|
void Login(ApiCredentials credentials);
|
||||||
Task<string> GetLastInstallerName(string folder);
|
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
|
public class AzaionApi(HttpClient client) : IAzaionApi
|
||||||
@@ -31,9 +31,9 @@ public class AzaionApi(HttpClient client) : IAzaionApi
|
|||||||
return res?.FirstOrDefault() ?? "";
|
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 fileStream = await response.Content.ReadAsStreamAsync();
|
||||||
var fileName = response.Content.Headers.ContentDisposition?.FileName?.Trim('"') ?? "installer.exe";
|
var fileName = response.Content.Headers.ContentDisposition?.FileName?.Trim('"') ?? "installer.exe";
|
||||||
return (fileName, fileStream);
|
return (fileName, fileStream);
|
||||||
|
|||||||
@@ -3,5 +3,6 @@ namespace Azaion.LoaderUI;
|
|||||||
public static class ConstantsLoader
|
public static class ConstantsLoader
|
||||||
{
|
{
|
||||||
public const string SUITE_FOLDER = "suite";
|
public const string SUITE_FOLDER = "suite";
|
||||||
|
public const string SUITE_STAGE_FOLDER = "suite-stage";
|
||||||
public const int EXTERNAL_LOADER_PORT = 5020;
|
public const int EXTERNAL_LOADER_PORT = 5020;
|
||||||
}
|
}
|
||||||
@@ -2,5 +2,5 @@ namespace Azaion.LoaderUI;
|
|||||||
|
|
||||||
public class DirectoriesConfig
|
public class DirectoriesConfig
|
||||||
{
|
{
|
||||||
public string SuiteInstallerDirectory {get;set;} = null!;
|
public bool IsStage { get; set; } = false;
|
||||||
}
|
}
|
||||||
@@ -63,7 +63,7 @@ public partial class Login
|
|||||||
if (installerVersion > localVersion)
|
if (installerVersion > localVersion)
|
||||||
{
|
{
|
||||||
TbStatus.Text = $"Updating from {localVersion} to {installerVersion}...";
|
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);
|
var localFileStream = new FileStream(installerName, FileMode.Create, FileAccess.Write);
|
||||||
await stream.CopyToAsync(localFileStream);
|
await stream.CopyToAsync(localFileStream);
|
||||||
localFileStream.Close();
|
localFileStream.Close();
|
||||||
@@ -164,9 +164,10 @@ public partial class Login
|
|||||||
private async Task<Version?> GetInstallerVer()
|
private async Task<Version?> GetInstallerVer()
|
||||||
{
|
{
|
||||||
TbStatus.Text = "Checking for the newer version...";
|
TbStatus.Text = "Checking for the newer version...";
|
||||||
var installerDir = string.IsNullOrWhiteSpace(_dirConfig?.SuiteInstallerDirectory)
|
var installerDir = _dirConfig?.IsStage ?? false
|
||||||
? ConstantsLoader.SUITE_FOLDER
|
? ConstantsLoader.SUITE_FOLDER
|
||||||
: _dirConfig.SuiteInstallerDirectory;
|
: ConstantsLoader.SUITE_STAGE_FOLDER;
|
||||||
|
|
||||||
var installerName = await _azaionApi.GetLastInstallerName(installerDir);
|
var installerName = await _azaionApi.GetLastInstallerName(installerDir);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"DirectoriesConfig":
|
"DirectoriesConfig":
|
||||||
{
|
{
|
||||||
"SuiteInstallerDirectory": null
|
"IsStage": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"DirectoriesConfig":
|
"DirectoriesConfig":
|
||||||
{
|
{
|
||||||
"SuiteInstallerDirectory": "suite-stage"
|
"IsStage": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user