diff --git a/Directory.Packages.props b/Directory.Packages.props index 638c47a47..78f9acd59 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -44,7 +44,7 @@ - + diff --git a/src/Ryujinx/Common/ApplicationHelper.cs b/src/Ryujinx/Common/ApplicationHelper.cs index afdab3af5..3efd9ed62 100644 --- a/src/Ryujinx/Common/ApplicationHelper.cs +++ b/src/Ryujinx/Common/ApplicationHelper.cs @@ -1,6 +1,5 @@ using Avalonia.Platform.Storage; using Avalonia.Threading; -using Gommon; using LibHac; using LibHac.Account; using LibHac.Common; @@ -411,7 +410,7 @@ namespace Ryujinx.Ava.Common public static async Task ExtractAoc(IStorageProvider storageProvider, string updateFilePath, string updateName) { - Optional result = await storageProvider.OpenSingleFolderPickerAsync(new FolderPickerOpenOptions + Gommon.Optional result = await storageProvider.OpenSingleFolderPickerAsync(new FolderPickerOpenOptions { Title = LocaleManager.Instance[LocaleKeys.FolderDialogExtractTitle] }); @@ -424,7 +423,7 @@ namespace Ryujinx.Ava.Common public static async Task ExtractSection(IStorageProvider storageProvider, NcaSectionType ncaSectionType, string titleFilePath, string titleName, int programIndex = 0) { - Optional result = await storageProvider.OpenSingleFolderPickerAsync(new FolderPickerOpenOptions + Gommon.Optional result = await storageProvider.OpenSingleFolderPickerAsync(new FolderPickerOpenOptions { Title = LocaleManager.Instance[LocaleKeys.FolderDialogExtractTitle] }); diff --git a/src/Ryujinx/Systems/AppLibrary/ApplicationLibrary.cs b/src/Ryujinx/Systems/AppLibrary/ApplicationLibrary.cs index 313a43358..48bc1571a 100644 --- a/src/Ryujinx/Systems/AppLibrary/ApplicationLibrary.cs +++ b/src/Ryujinx/Systems/AppLibrary/ApplicationLibrary.cs @@ -117,7 +117,7 @@ namespace Ryujinx.Ava.Systems.AppLibrary using UniqueRef npdmFile = new(); - Result result = pfs.OpenFile(ref npdmFile.Ref, "/main.npdm".ToU8Span(), OpenMode.Read); + LibHac.Result result = pfs.OpenFile(ref npdmFile.Ref, "/main.npdm".ToU8Span(), OpenMode.Read); if (ResultFs.PathNotFound.Includes(result)) { diff --git a/src/Ryujinx/Systems/Updater/Updater.GitLab.cs b/src/Ryujinx/Systems/Updater/Updater.GitLab.cs index 3411daa5d..17f01c136 100644 --- a/src/Ryujinx/Systems/Updater/Updater.GitLab.cs +++ b/src/Ryujinx/Systems/Updater/Updater.GitLab.cs @@ -7,6 +7,7 @@ using Ryujinx.Common.Logging; using Ryujinx.Systems.Update.Client; using Ryujinx.Systems.Update.Common; using System; +using System.Net.Http; using System.Threading.Tasks; namespace Ryujinx.Ava.Systems @@ -14,16 +15,38 @@ namespace Ryujinx.Ava.Systems internal static partial class Updater { private static VersionResponse _versionResponse; + private static UpdateClient _updateClient; - private static UpdateClient CreateUpdateClient() - => UpdateClient.Builder() + private static async Task> QueryLatestVersionAsync() + { + _updateClient ??= UpdateClient.Builder() .WithServerEndpoint("https://update.ryujinx.app") // This is the default, and doesn't need to be provided; it's here for transparency. .WithLogger((format, args, caller) => Logger.Info?.Print( LogClass.Application, args.Length is 0 ? format : format.Format(args), caller: caller) - ); + ); + + try + { + return await _updateClient.QueryLatestAsync(ReleaseInformation.IsCanaryBuild + ? ReleaseChannel.Canary + : ReleaseChannel.Stable); + } + catch (HttpRequestException hre) + when (hre.HttpRequestError is HttpRequestError.ConnectionError) + { + return Return.Failure( + new MessageError("Connection error occurred. Is your internet down?")); + } + catch (HttpRequestException hre) + when (hre.HttpRequestError is HttpRequestError.NameResolutionError) + { + return Return.Failure( + new MessageError("DNS resolution error occurred. Is your internet down?")); + } + } public static async Task> CheckVersionAsync(bool showVersionUpToDate = false) { @@ -41,22 +64,18 @@ namespace Ryujinx.Ava.Systems return default; } - using UpdateClient updateClient = CreateUpdateClient(); - try { - _versionResponse = await updateClient.QueryLatestAsync(ReleaseInformation.IsCanaryBuild - ? ReleaseChannel.Canary - : ReleaseChannel.Stable); + _versionResponse = await QueryLatestVersionAsync().Then(x => x.Unwrap()); } catch (Exception e) { - Logger.Error?.Print(LogClass.Application, $"An error occurred when requesting for updates ({e.GetType().AsFullNamePrettyString()}): {e.Message}"); + Logger.Error?.Print(LogClass.Application, $"{e.GetType().AsPrettyString()} thrown when requesting updates: {e.Message}"); _running = false; return default; } - + if (_versionResponse == null) { // logging is done via the UpdateClient library