diff options
Diffstat (limited to 'Ryujinx/Modules/Updater/Updater.cs')
-rw-r--r-- | Ryujinx/Modules/Updater/Updater.cs | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/Ryujinx/Modules/Updater/Updater.cs b/Ryujinx/Modules/Updater/Updater.cs index 5ad5924e..3f186ce6 100644 --- a/Ryujinx/Modules/Updater/Updater.cs +++ b/Ryujinx/Modules/Updater/Updater.cs @@ -2,14 +2,14 @@ using Gtk; using ICSharpCode.SharpZipLib.GZip; using ICSharpCode.SharpZipLib.Tar; using ICSharpCode.SharpZipLib.Zip; -using Newtonsoft.Json.Linq; using Ryujinx.Common; using Ryujinx.Common.Logging; +using Ryujinx.Common.Utilities; using Ryujinx.Ui; +using Ryujinx.Ui.Common.Models.Github; using Ryujinx.Ui.Widgets; using System; using System.Collections.Generic; -using System.Diagnostics; using System.IO; using System.Linq; using System.Net; @@ -38,6 +38,8 @@ namespace Ryujinx.Modules private static string _buildUrl; private static long _buildSize; + private static readonly GithubReleasesJsonSerializerContext SerializerContext = new(JsonHelper.GetDefaultSerializerOptions()); + // On Windows, GtkSharp.Dependencies adds these extra dirs that must be cleaned during updates. private static readonly string[] WindowsDependencyDirs = new string[] { "bin", "etc", "lib", "share" }; @@ -107,22 +109,16 @@ namespace Ryujinx.Modules // Fetch latest build information string fetchedJson = await jsonClient.GetStringAsync(buildInfoURL); - JObject jsonRoot = JObject.Parse(fetchedJson); - JToken assets = jsonRoot["assets"]; - - _buildVer = (string)jsonRoot["name"]; + var fetched = JsonHelper.Deserialize(fetchedJson, SerializerContext.GithubReleasesJsonResponse); + _buildVer = fetched.Name; - foreach (JToken asset in assets) + foreach (var asset in fetched.Assets) { - string assetName = (string)asset["name"]; - string assetState = (string)asset["state"]; - string downloadURL = (string)asset["browser_download_url"]; - - if (assetName.StartsWith("ryujinx") && assetName.EndsWith(_platformExt)) + if (asset.Name.StartsWith("ryujinx") && asset.Name.EndsWith(_platformExt)) { - _buildUrl = downloadURL; + _buildUrl = asset.BrowserDownloadUrl; - if (assetState != "uploaded") + if (asset.State != "uploaded") { if (showVersionUpToDate) { |