mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 22:56:29 +00:00
make version check more resilient to api installer availability
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user