From b2c5d4f8d77b481002c73ded4b6bdca8a6b871f3 Mon Sep 17 00:00:00 2001 From: yell0wsuit <5692900+yell0wsuit@users.noreply.github.com> Date: Wed, 17 Apr 2024 00:41:18 +0700 Subject: [PATCH] Refactor part 4 --- src/Ryujinx/Modules/Updater/Updater.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Ryujinx/Modules/Updater/Updater.cs b/src/Ryujinx/Modules/Updater/Updater.cs index fb247bf35..82debc332 100644 --- a/src/Ryujinx/Modules/Updater/Updater.cs +++ b/src/Ryujinx/Modules/Updater/Updater.cs @@ -68,7 +68,7 @@ namespace Ryujinx.Modules DetectPlatform(); - Version currentVersion = GetCurrentVersion(); + Version currentVersion = await GetCurrentVersion(); if (currentVersion == null) { return; @@ -110,7 +110,7 @@ namespace Ryujinx.Modules } } - private static Version GetCurrentVersion() + private static async Task GetCurrentVersion() { try { @@ -120,7 +120,7 @@ namespace Ryujinx.Modules { Logger.Error?.Print(LogClass.Application, "Failed to convert the current Ryujinx version!"); - ContentDialogHelper.CreateWarningDialog( + await ContentDialogHelper.CreateWarningDialog( LocaleManager.Instance[LocaleKeys.DialogUpdaterConvertFailedMessage], LocaleManager.Instance[LocaleKeys.DialogUpdaterCancelUpdateMessage]); _running = false; @@ -195,6 +195,7 @@ namespace Ryujinx.Modules } } + // Fetch build size information to learn chunk sizes. private static async Task FetchBuildSizeInfo() { try @@ -310,7 +311,10 @@ namespace Ryujinx.Modules } 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")) { ryuName = ryuName.Replace(".Ava", ""); @@ -327,7 +331,7 @@ namespace Ryujinx.Modules ryuName = OperatingSystem.IsWindows() ? "Ryujinx.exe" : "Ryujinx"; } - ProcessStartInfo processStart = new ProcessStartInfo(ryuName) + ProcessStartInfo processStart = new(ryuName) { UseShellExecute = true, WorkingDirectory = executableDirectory, @@ -418,7 +422,7 @@ namespace Ryujinx.Modules byte[] buffer = new byte[8192]; using var request = new HttpRequestMessage(HttpMethod.Get, url); 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 memoryStream = new MemoryStream(); int bytesRead;