mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 08:36: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))
|
if (string.IsNullOrWhiteSpace(creds.Email) || string.IsNullOrWhiteSpace(creds.Password))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SetControlsStatus(isLoading: true);
|
SetControlsStatus(isLoading: true);
|
||||||
@@ -56,8 +56,8 @@ public partial class Login
|
|||||||
Validate(creds);
|
Validate(creds);
|
||||||
|
|
||||||
TbStatus.Foreground = Brushes.Black;
|
TbStatus.Foreground = Brushes.Black;
|
||||||
var installerVersion = await GetInstallerVer();
|
|
||||||
var localVersion = Constants.GetLocalVersion();
|
var localVersion = Constants.GetLocalVersion();
|
||||||
|
var installerVersion = await GetInstallerVer() ?? localVersion;
|
||||||
var credsEncrypted = Security.Encrypt(creds);
|
var credsEncrypted = Security.Encrypt(creds);
|
||||||
|
|
||||||
if (installerVersion > localVersion)
|
if (installerVersion > localVersion)
|
||||||
@@ -159,18 +159,28 @@ public partial class Login
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 = string.IsNullOrWhiteSpace(_dirConfig?.SuiteInstallerDirectory)
|
||||||
? ConstantsLoader.SUITE_FOLDER
|
? ConstantsLoader.SUITE_FOLDER
|
||||||
: _dirConfig.SuiteInstallerDirectory;
|
: _dirConfig.SuiteInstallerDirectory;
|
||||||
var installerName = await _azaionApi.GetLastInstallerName(installerDir);
|
var installerName = await _azaionApi.GetLastInstallerName(installerDir);
|
||||||
var match = Regex.Match(installerName, @"\d+(\.\d+)+");
|
try
|
||||||
if (!match.Success)
|
{
|
||||||
throw new Exception($"Can't find version in {installerName}");
|
var match = Regex.Match(installerName, @"\d+(\.\d+)+");
|
||||||
return new Version(match.Value);
|
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();
|
private void CloseClick(object sender, RoutedEventArgs e) => Close();
|
||||||
|
|||||||
Reference in New Issue
Block a user