Remove inner try on Updater.CheckGitLabVersionAsync & apply formatting to file

This commit is contained in:
GreemDev 2025-06-03 17:56:11 -05:00
parent 64ecd514f2
commit 91248bdd32

View File

@ -19,11 +19,13 @@ namespace Ryujinx.Ava.Systems
{
private static GitLabReleaseChannels.ChannelType _currentGitLabReleaseChannel;
private static async Task<Optional<(Version Current, Version Incoming)>> CheckGitLabVersionAsync(bool showVersionUpToDate = false)
private static async Task<Optional<(Version Current, Version Incoming)>> CheckGitLabVersionAsync(
bool showVersionUpToDate = false)
{
if (!Version.TryParse(Program.Version, out Version currentVersion))
{
Logger.Error?.Print(LogClass.Application, $"Failed to convert the current {RyujinxApp.FullAppName} version!");
Logger.Error?.Print(LogClass.Application,
$"Failed to convert the current {RyujinxApp.FullAppName} version!");
await ContentDialogHelper.CreateWarningDialog(
LocaleManager.Instance[LocaleKeys.DialogUpdaterConvertFailedMessage],
@ -37,11 +39,12 @@ namespace Ryujinx.Ava.Systems
Logger.Info?.Print(LogClass.Application, "Checking for updates from https://git.ryujinx.app.");
// Get latest version number from GitLab API
try
{
using HttpClient jsonClient = ConstructHttpClient();
jsonClient.Timeout = TimeSpan.FromSeconds(10); // GitLab instance is located in Ukraine. Connection times will vary across the world.
jsonClient.Timeout =
TimeSpan.FromSeconds(
10); // GitLab instance is located in Ukraine. Connection times will vary across the world.
if (_currentGitLabReleaseChannel == null)
{
@ -64,7 +67,7 @@ namespace Ryujinx.Ava.Systems
link.AssetName.StartsWith("ryujinx") && link.AssetName.EndsWith(_platformExt)
)?.Url;
// If build not done, assume no new update are available.
// If build URL not found, assume no new update are available.
if (_buildUrl is null)
{
if (showVersionUpToDate)
@ -85,22 +88,12 @@ namespace Ryujinx.Ava.Systems
return default;
}
}
catch (Exception exception)
{
Logger.Error?.Print(LogClass.Application, exception.Message);
await ContentDialogHelper.CreateErrorDialog(
LocaleManager.Instance[LocaleKeys.DialogUpdaterFailedToGetVersionMessage]);
_running = false;
return default;
}
if (!Version.TryParse(_buildVer, out Version newVersion))
{
Logger.Error?.Print(LogClass.Application, $"Failed to convert the received {RyujinxApp.FullAppName} version from GitHub!");
Logger.Error?.Print(LogClass.Application,
$"Failed to convert the received {RyujinxApp.FullAppName} version from GitLab!");
await ContentDialogHelper.CreateWarningDialog(
LocaleManager.Instance[LocaleKeys.DialogUpdaterConvertFailedGithubMessage],
@ -120,23 +113,20 @@ namespace Ryujinx.Ava.Systems
public class GitLabReleaseChannels
{
public static async Task<GitLabReleaseChannels> GetAsync(HttpClient httpClient)
=> await httpClient.GetFromJsonAsync("https://git.ryujinx.app/ryubing/ryujinx/-/snippets/1/raw/main/meta.json", GitLabReleaseChannelPairContext.Default.GitLabReleaseChannels);
=> await httpClient.GetFromJsonAsync(
"https://git.ryujinx.app/ryubing/ryujinx/-/snippets/1/raw/main/meta.json",
GitLabReleaseChannelPairContext.Default.GitLabReleaseChannels);
[JsonPropertyName("stable")]
public ChannelType Stable { get; set; }
[JsonPropertyName("canary")]
public ChannelType Canary { get; set; }
[JsonPropertyName("stable")] public ChannelType Stable { get; set; }
[JsonPropertyName("canary")] public ChannelType Canary { get; set; }
public class ChannelType
{
[JsonPropertyName("id")]
public long Id { get; set; }
[JsonPropertyName("id")] public long Id { get; set; }
[JsonPropertyName("group")]
public string Group { get; set; }
[JsonPropertyName("group")] public string Group { get; set; }
[JsonPropertyName("project")]
public string Project { get; set; }
[JsonPropertyName("project")] public string Project { get; set; }
public string UrlFormat => $"https://git.ryujinx.app/{ToString()}/-/releases/{{0}}";