Refactor part 4

This commit is contained in:
yell0wsuit 2024-04-17 00:41:18 +07:00
parent 2bfc3d59fb
commit b2c5d4f8d7
No known key found for this signature in database
GPG key ID: 5B4F198A9800F6F4

View file

@ -68,7 +68,7 @@ namespace Ryujinx.Modules
DetectPlatform(); DetectPlatform();
Version currentVersion = GetCurrentVersion(); Version currentVersion = await GetCurrentVersion();
if (currentVersion == null) if (currentVersion == null)
{ {
return; return;
@ -110,7 +110,7 @@ namespace Ryujinx.Modules
} }
} }
private static Version GetCurrentVersion() private static async Task<Version> GetCurrentVersion()
{ {
try try
{ {
@ -120,7 +120,7 @@ namespace Ryujinx.Modules
{ {
Logger.Error?.Print(LogClass.Application, "Failed to convert the current Ryujinx version!"); Logger.Error?.Print(LogClass.Application, "Failed to convert the current Ryujinx version!");
ContentDialogHelper.CreateWarningDialog( await ContentDialogHelper.CreateWarningDialog(
LocaleManager.Instance[LocaleKeys.DialogUpdaterConvertFailedMessage], LocaleManager.Instance[LocaleKeys.DialogUpdaterConvertFailedMessage],
LocaleManager.Instance[LocaleKeys.DialogUpdaterCancelUpdateMessage]); LocaleManager.Instance[LocaleKeys.DialogUpdaterCancelUpdateMessage]);
_running = false; _running = false;
@ -195,6 +195,7 @@ namespace Ryujinx.Modules
} }
} }
// Fetch build size information to learn chunk sizes.
private static async Task FetchBuildSizeInfo() private static async Task FetchBuildSizeInfo()
{ {
try try
@ -310,7 +311,10 @@ namespace Ryujinx.Modules
} }
else else
{ {
string ryuName = Path.GetFileName(Environment.ProcessPath) ?? (OperatingSystem.IsWindows() ? "Ryujinx.exe" : "Ryujinx"); string ryuName = Path.GetFileName(Environment.ProcessPath) ?? string.Empty;
// Migration: Start the updated binary.
// TODO: Remove this in a future update.
if (ryuName.StartsWith("Ryujinx.Ava")) if (ryuName.StartsWith("Ryujinx.Ava"))
{ {
ryuName = ryuName.Replace(".Ava", ""); ryuName = ryuName.Replace(".Ava", "");
@ -327,7 +331,7 @@ namespace Ryujinx.Modules
ryuName = OperatingSystem.IsWindows() ? "Ryujinx.exe" : "Ryujinx"; ryuName = OperatingSystem.IsWindows() ? "Ryujinx.exe" : "Ryujinx";
} }
ProcessStartInfo processStart = new ProcessStartInfo(ryuName) ProcessStartInfo processStart = new(ryuName)
{ {
UseShellExecute = true, UseShellExecute = true,
WorkingDirectory = executableDirectory, WorkingDirectory = executableDirectory,
@ -418,7 +422,7 @@ namespace Ryujinx.Modules
byte[] buffer = new byte[8192]; byte[] buffer = new byte[8192];
using var request = new HttpRequestMessage(HttpMethod.Get, url); using var request = new HttpRequestMessage(HttpMethod.Get, url);
request.Headers.Range = new RangeHeaderValue(start, end); request.Headers.Range = new RangeHeaderValue(start, end);
HttpResponseMessage response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead); HttpResponseMessage response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false);
using var stream = await response.Content.ReadAsStreamAsync(); using var stream = await response.Content.ReadAsStreamAsync();
using var memoryStream = new MemoryStream(); using var memoryStream = new MemoryStream();
int bytesRead; int bytesRead;