mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-06-27 22:06:24 +02:00
Remove GitHub updater support.
This commit is contained in:
parent
c58272ac20
commit
0409c15903
4 changed files with 29 additions and 268 deletions
|
@ -1,190 +0,0 @@
|
|||
using Gommon;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Ava.Common.Models.Github;
|
||||
using Ryujinx.Ava.UI.Helpers;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Helper;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Common.Utilities;
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ryujinx.Ava.Systems
|
||||
{
|
||||
internal static partial class Updater
|
||||
{
|
||||
private static GitHubReleaseChannels.Channel? _currentGitHubReleaseChannel;
|
||||
|
||||
private static async Task<Optional<(Version Current, Version Incoming)>> CheckGitHubVersionAsync(bool showVersionUpToDate = false)
|
||||
{
|
||||
if (!Version.TryParse(Program.Version, out Version currentVersion))
|
||||
{
|
||||
Logger.Error?.Print(LogClass.Application, $"Failed to convert the current {RyujinxApp.FullAppName} version!");
|
||||
|
||||
await ContentDialogHelper.CreateWarningDialog(
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterConvertFailedMessage],
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterCancelUpdateMessage]);
|
||||
|
||||
_running = false;
|
||||
|
||||
return default;
|
||||
}
|
||||
|
||||
Logger.Info?.Print(LogClass.Application, "Checking for updates from GitHub.");
|
||||
|
||||
// Get latest version number from GitHub API
|
||||
try
|
||||
{
|
||||
using HttpClient jsonClient = ConstructHttpClient();
|
||||
|
||||
if (_currentGitHubReleaseChannel == null)
|
||||
{
|
||||
GitHubReleaseChannels releaseChannels = await GitHubReleaseChannels.GetAsync(jsonClient);
|
||||
|
||||
_currentGitHubReleaseChannel = ReleaseInformation.IsCanaryBuild
|
||||
? releaseChannels.Canary
|
||||
: releaseChannels.Stable;
|
||||
|
||||
Logger.Info?.Print(LogClass.Application, $"Loaded GitHub release channel for '{(ReleaseInformation.IsCanaryBuild ? "canary" : "stable")}'");
|
||||
|
||||
_changelogUrlFormat = _currentGitHubReleaseChannel.Value.UrlFormat;
|
||||
}
|
||||
|
||||
string fetchedJson = await jsonClient.GetStringAsync(_currentGitHubReleaseChannel.Value.GetLatestReleaseApiUrl());
|
||||
GithubReleasesJsonResponse fetched = JsonHelper.Deserialize(fetchedJson, _ghSerializerContext.GithubReleasesJsonResponse);
|
||||
_buildVer = fetched.TagName;
|
||||
|
||||
foreach (GithubReleaseAssetJsonResponse asset in fetched.Assets)
|
||||
{
|
||||
if (asset.Name.StartsWith("ryujinx") && asset.Name.EndsWith(_platformExt))
|
||||
{
|
||||
_buildUrl = asset.BrowserDownloadUrl;
|
||||
|
||||
if (asset.State != "uploaded")
|
||||
{
|
||||
if (showVersionUpToDate)
|
||||
{
|
||||
UserResult userResult = await ContentDialogHelper.CreateUpdaterUpToDateInfoDialog(
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterAlreadyOnLatestVersionMessage],
|
||||
string.Empty);
|
||||
|
||||
if (userResult is UserResult.Ok)
|
||||
{
|
||||
OpenHelper.OpenUrl(_changelogUrlFormat.Format(currentVersion));
|
||||
}
|
||||
}
|
||||
|
||||
Logger.Info?.Print(LogClass.Application, "Up to date.");
|
||||
|
||||
_running = false;
|
||||
|
||||
return default;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If build not done, assume no new update is available.
|
||||
if (_buildUrl is null)
|
||||
{
|
||||
if (showVersionUpToDate)
|
||||
{
|
||||
UserResult userResult = await ContentDialogHelper.CreateUpdaterUpToDateInfoDialog(
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterAlreadyOnLatestVersionMessage],
|
||||
string.Empty);
|
||||
|
||||
if (userResult is UserResult.Ok)
|
||||
{
|
||||
OpenHelper.OpenUrl(_changelogUrlFormat.Format(currentVersion));
|
||||
}
|
||||
}
|
||||
|
||||
Logger.Info?.Print(LogClass.Application, "Up to date.");
|
||||
|
||||
_running = false;
|
||||
|
||||
return default;
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Logger.Error?.Print(LogClass.Application, exception.Message);
|
||||
|
||||
await ContentDialogHelper.CreateErrorDialog(
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterFailedToGetVersionMessage]);
|
||||
|
||||
_running = false;
|
||||
|
||||
return default;
|
||||
}
|
||||
|
||||
if (!Version.TryParse(_buildVer, out Version newVersion))
|
||||
{
|
||||
Logger.Error?.Print(LogClass.Application, $"Failed to convert the received {RyujinxApp.FullAppName} version from GitHub!");
|
||||
|
||||
await ContentDialogHelper.CreateWarningDialog(
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterConvertFailedGithubMessage],
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterCancelUpdateMessage]);
|
||||
|
||||
_running = false;
|
||||
|
||||
return default;
|
||||
}
|
||||
|
||||
return (currentVersion, newVersion);
|
||||
}
|
||||
}
|
||||
|
||||
public readonly struct GitHubReleaseChannels
|
||||
{
|
||||
public static async Task<GitHubReleaseChannels> GetAsync(HttpClient httpClient)
|
||||
{
|
||||
ReleaseChannelPair releaseChannelPair = await httpClient.GetFromJsonAsync("https://ryujinx.app/api/release-channels", ReleaseChannelPairContext.Default.ReleaseChannelPair);
|
||||
return new GitHubReleaseChannels(releaseChannelPair);
|
||||
}
|
||||
|
||||
internal GitHubReleaseChannels(ReleaseChannelPair channelPair)
|
||||
{
|
||||
Stable = new Channel(channelPair.Stable);
|
||||
Canary = new Channel(channelPair.Canary);
|
||||
}
|
||||
|
||||
public readonly Channel Stable;
|
||||
public readonly Channel Canary;
|
||||
|
||||
public readonly struct Channel
|
||||
{
|
||||
public Channel(string raw)
|
||||
{
|
||||
string[] parts = raw.Split('/');
|
||||
Owner = parts[0];
|
||||
Repo = parts[1];
|
||||
}
|
||||
|
||||
public readonly string Owner;
|
||||
public readonly string Repo;
|
||||
|
||||
public string UrlFormat => $"https://github.com/{ToString()}/releases/{{0}}";
|
||||
|
||||
public override string ToString() => $"{Owner}/{Repo}";
|
||||
|
||||
public string GetLatestReleaseApiUrl() =>
|
||||
$"https://api.github.com/repos/{ToString()}/releases/latest";
|
||||
}
|
||||
}
|
||||
|
||||
[JsonSerializable(typeof(ReleaseChannelPair))]
|
||||
partial class ReleaseChannelPairContext : JsonSerializerContext;
|
||||
|
||||
class ReleaseChannelPair
|
||||
{
|
||||
[JsonPropertyName("stable")]
|
||||
public string Stable { get; set; }
|
||||
[JsonPropertyName("canary")]
|
||||
public string Canary { get; set; }
|
||||
}
|
||||
}
|
|
@ -41,7 +41,7 @@ namespace Ryujinx.Ava.Systems
|
|||
return $"https://update.ryujinx.app/latest/query?os={os}&arch={arch}&rc={rc}";
|
||||
}
|
||||
|
||||
private static async Task<Optional<(Version Current, Version Incoming)>> CheckGitLabVersionAsync(bool showVersionUpToDate = false)
|
||||
public static async Task<Optional<(Version Current, Version Incoming)>> CheckVersionAsync(bool showVersionUpToDate = false)
|
||||
{
|
||||
if (!Version.TryParse(Program.Version, out Version currentVersion))
|
||||
{
|
||||
|
@ -68,12 +68,9 @@ namespace Ryujinx.Ava.Systems
|
|||
|
||||
Logger.Info?.Print(LogClass.Application, $"Checking for updates from {updateUrl}.");
|
||||
|
||||
// Get latest version number from GitLab API
|
||||
// Get latest version number from update.ryujinx.app API
|
||||
using HttpClient jsonClient = ConstructHttpClient();
|
||||
|
||||
// GitLab instance is located in Ukraine. Connection times will vary across the world.
|
||||
jsonClient.Timeout = TimeSpan.FromSeconds(10);
|
||||
|
||||
try
|
||||
{
|
||||
UpdaterResponse response =
|
||||
|
@ -85,9 +82,10 @@ namespace Ryujinx.Ava.Systems
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new AggregateException(
|
||||
$"An error occurred when parsing JSON response from API ({e.GetType().AsFullNamePrettyString()}): {e.Message}",
|
||||
e);
|
||||
Logger.Error?.Print(LogClass.Application, $"An error occurred when parsing JSON response from API ({e.GetType().AsFullNamePrettyString()}): {e.Message}");
|
||||
|
||||
_running = false;
|
||||
return default;
|
||||
}
|
||||
|
||||
// If build URL not found, assume no new update is available.
|
||||
|
@ -116,10 +114,10 @@ namespace Ryujinx.Ava.Systems
|
|||
if (!Version.TryParse(_buildVer, out Version newVersion))
|
||||
{
|
||||
Logger.Error?.Print(LogClass.Application,
|
||||
$"Failed to convert the received {RyujinxApp.FullAppName} version from GitLab!");
|
||||
$"Failed to convert the received {RyujinxApp.FullAppName} version from the update server!");
|
||||
|
||||
await ContentDialogHelper.CreateWarningDialog(
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterConvertFailedGithubMessage],
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterConvertFailedServerMessage],
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterCancelUpdateMessage]);
|
||||
|
||||
_running = false;
|
||||
|
|
|
@ -31,9 +31,6 @@ namespace Ryujinx.Ava.Systems
|
|||
{
|
||||
internal static partial class Updater
|
||||
{
|
||||
private static readonly GithubReleasesJsonSerializerContext _ghSerializerContext = new(JsonHelper.GetDefaultSerializerOptions());
|
||||
|
||||
private static readonly string _platformExt = BuildPlatformExtension();
|
||||
private static readonly string _homeDir = AppDomain.CurrentDomain.BaseDirectory;
|
||||
private static readonly string _updateDir = Path.Combine(Path.GetTempPath(), "Ryujinx", "update");
|
||||
private static readonly string _updatePublishDir = Path.Combine(_updateDir, "publish");
|
||||
|
@ -48,25 +45,6 @@ namespace Ryujinx.Ava.Systems
|
|||
private static readonly string[] _windowsDependencyDirs = [];
|
||||
|
||||
private static string _changelogUrlFormat = null;
|
||||
|
||||
public static async Task<Optional<(Version, Version)>> CheckVersionAsync(bool showVersionUpToDate = false)
|
||||
{
|
||||
Optional<(Version, Version)> versionTuple;
|
||||
|
||||
try
|
||||
{
|
||||
versionTuple = await CheckGitLabVersionAsync(showVersionUpToDate);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error?.PrintMsg(LogClass.Application, "Update checking from GitLab failed; falling back to GitHub.");
|
||||
Logger.Error?.PrintMsg(LogClass.Application, e.Message);
|
||||
versionTuple = await CheckGitHubVersionAsync(showVersionUpToDate);
|
||||
}
|
||||
|
||||
return versionTuple;
|
||||
}
|
||||
|
||||
|
||||
public static async Task BeginUpdateAsync(bool showVersionUpToDate = false)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue