improvement: Make the updater log a special error message in some cases

specifically about potentially not being connected to the internet on a connection error or name resolution error
This commit is contained in:
GreemDev
2025-09-05 03:12:15 -05:00
parent 931ec44406
commit 23eb9a3043
4 changed files with 33 additions and 15 deletions

View File

@@ -44,7 +44,7 @@
<PackageVersion Include="Ryujinx.SDL2-CS" Version="2.30.0-build32" /> <PackageVersion Include="Ryujinx.SDL2-CS" Version="2.30.0-build32" />
<PackageVersion Include="Ryujinx.UpdateClient" Version="1.0.44" /> <PackageVersion Include="Ryujinx.UpdateClient" Version="1.0.44" />
<PackageVersion Include="Ryujinx.Systems.Update.Common" Version="1.0.44" /> <PackageVersion Include="Ryujinx.Systems.Update.Common" Version="1.0.44" />
<PackageVersion Include="Gommon" Version="2.7.1.1" /> <PackageVersion Include="Gommon" Version="2.7.2.1" />
<PackageVersion Include="securifybv.ShellLink" Version="0.1.0" /> <PackageVersion Include="securifybv.ShellLink" Version="0.1.0" />
<PackageVersion Include="Sep" Version="0.11.1" /> <PackageVersion Include="Sep" Version="0.11.1" />
<PackageVersion Include="shaderc.net" Version="0.1.0" /> <PackageVersion Include="shaderc.net" Version="0.1.0" />

View File

@@ -1,6 +1,5 @@
using Avalonia.Platform.Storage; using Avalonia.Platform.Storage;
using Avalonia.Threading; using Avalonia.Threading;
using Gommon;
using LibHac; using LibHac;
using LibHac.Account; using LibHac.Account;
using LibHac.Common; using LibHac.Common;
@@ -411,7 +410,7 @@ namespace Ryujinx.Ava.Common
public static async Task ExtractAoc(IStorageProvider storageProvider, string updateFilePath, string updateName) public static async Task ExtractAoc(IStorageProvider storageProvider, string updateFilePath, string updateName)
{ {
Optional<IStorageFolder> result = await storageProvider.OpenSingleFolderPickerAsync(new FolderPickerOpenOptions Gommon.Optional<IStorageFolder> result = await storageProvider.OpenSingleFolderPickerAsync(new FolderPickerOpenOptions
{ {
Title = LocaleManager.Instance[LocaleKeys.FolderDialogExtractTitle] 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) public static async Task ExtractSection(IStorageProvider storageProvider, NcaSectionType ncaSectionType, string titleFilePath, string titleName, int programIndex = 0)
{ {
Optional<IStorageFolder> result = await storageProvider.OpenSingleFolderPickerAsync(new FolderPickerOpenOptions Gommon.Optional<IStorageFolder> result = await storageProvider.OpenSingleFolderPickerAsync(new FolderPickerOpenOptions
{ {
Title = LocaleManager.Instance[LocaleKeys.FolderDialogExtractTitle] Title = LocaleManager.Instance[LocaleKeys.FolderDialogExtractTitle]
}); });

View File

@@ -117,7 +117,7 @@ namespace Ryujinx.Ava.Systems.AppLibrary
using UniqueRef<IFile> npdmFile = new(); using UniqueRef<IFile> 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)) if (ResultFs.PathNotFound.Includes(result))
{ {

View File

@@ -7,6 +7,7 @@ using Ryujinx.Common.Logging;
using Ryujinx.Systems.Update.Client; using Ryujinx.Systems.Update.Client;
using Ryujinx.Systems.Update.Common; using Ryujinx.Systems.Update.Common;
using System; using System;
using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Ryujinx.Ava.Systems namespace Ryujinx.Ava.Systems
@@ -14,16 +15,38 @@ namespace Ryujinx.Ava.Systems
internal static partial class Updater internal static partial class Updater
{ {
private static VersionResponse _versionResponse; private static VersionResponse _versionResponse;
private static UpdateClient _updateClient;
private static UpdateClient CreateUpdateClient() private static async Task<Return<VersionResponse>> QueryLatestVersionAsync()
=> UpdateClient.Builder() {
_updateClient ??= UpdateClient.Builder()
.WithServerEndpoint("https://update.ryujinx.app") // This is the default, and doesn't need to be provided; it's here for transparency. .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) => .WithLogger((format, args, caller) =>
Logger.Info?.Print( Logger.Info?.Print(
LogClass.Application, LogClass.Application,
args.Length is 0 ? format : format.Format(args), args.Length is 0 ? format : format.Format(args),
caller: caller) caller: caller)
); );
try
{
return await _updateClient.QueryLatestAsync(ReleaseInformation.IsCanaryBuild
? ReleaseChannel.Canary
: ReleaseChannel.Stable);
}
catch (HttpRequestException hre)
when (hre.HttpRequestError is HttpRequestError.ConnectionError)
{
return Return<VersionResponse>.Failure(
new MessageError("Connection error occurred. Is your internet down?"));
}
catch (HttpRequestException hre)
when (hre.HttpRequestError is HttpRequestError.NameResolutionError)
{
return Return<VersionResponse>.Failure(
new MessageError("DNS resolution error occurred. Is your internet down?"));
}
}
public static async Task<Optional<(Version Current, Version Incoming)>> CheckVersionAsync(bool showVersionUpToDate = false) public static async Task<Optional<(Version Current, Version Incoming)>> CheckVersionAsync(bool showVersionUpToDate = false)
{ {
@@ -41,22 +64,18 @@ namespace Ryujinx.Ava.Systems
return default; return default;
} }
using UpdateClient updateClient = CreateUpdateClient();
try try
{ {
_versionResponse = await updateClient.QueryLatestAsync(ReleaseInformation.IsCanaryBuild _versionResponse = await QueryLatestVersionAsync().Then(x => x.Unwrap());
? ReleaseChannel.Canary
: ReleaseChannel.Stable);
} }
catch (Exception e) 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; _running = false;
return default; return default;
} }
if (_versionResponse == null) if (_versionResponse == null)
{ {
// logging is done via the UpdateClient library // logging is done via the UpdateClient library