make version check more resilient to api installer availability

This commit is contained in:
Oleksandr Bezdieniezhnykh
2025-09-02 19:32:40 +03:00
parent d396677451
commit b2b2efe120
+18 -8
View File
@@ -48,7 +48,7 @@ public partial class Login
};
if (string.IsNullOrWhiteSpace(creds.Email) || string.IsNullOrWhiteSpace(creds.Password))
return;
try
{
SetControlsStatus(isLoading: true);
@@ -56,8 +56,8 @@ public partial class Login
Validate(creds);
TbStatus.Foreground = Brushes.Black;
var installerVersion = await GetInstallerVer();
var localVersion = Constants.GetLocalVersion();
var installerVersion = await GetInstallerVer() ?? localVersion;
var credsEncrypted = Security.Encrypt(creds);
if (installerVersion > localVersion)
@@ -159,18 +159,28 @@ public partial class Login
throw;
}
}
private async Task<Version> GetInstallerVer()
private async Task<Version?> GetInstallerVer()
{
TbStatus.Text = "Checking for the newer version...";
var installerDir = string.IsNullOrWhiteSpace(_dirConfig?.SuiteInstallerDirectory)
? ConstantsLoader.SUITE_FOLDER
: _dirConfig.SuiteInstallerDirectory;
var installerName = await _azaionApi.GetLastInstallerName(installerDir);
var match = Regex.Match(installerName, @"\d+(\.\d+)+");
if (!match.Success)
throw new Exception($"Can't find version in {installerName}");
return new Version(match.Value);
try
{
var match = Regex.Match(installerName, @"\d+(\.\d+)+");
if (!match.Success)
throw new Exception($"Can't find version in {installerName}");
return new Version(match.Value);
}
catch (Exception e)
{
TbStatus.Text = $"Exception during the check version {e.Message}";
_logger.LogError(e, e.Message);
await Task.Delay(1500);
return null;
}
}
private void CloseClick(object sender, RoutedEventArgs e) => Close();