Drop the update check - Steam updates the starter

The daily GitHub check, the top-bar button, the stable/staging channel and
"check now" go, with their settings and texts.
This commit is contained in:
maj00r
2026-10-04 18:46:38 +02:00
parent 6cedf8b6f6
commit 52ad490fb7
18 changed files with 0 additions and 775 deletions

View File

@@ -1,99 +0,0 @@
using System;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading;
using System.Threading.Tasks;
using StarterNG.Application.Abstractions;
using StarterNG.Domain.Settings;
namespace StarterNG.Infrastructure.Adapters;
public sealed class GitHubReleaseFeed : IReleaseFeed
{
private const string ReleasesUrl = "https://api.github.com/repos/MaSzyna-EU07/StarterNG/releases/";
/// <summary>The tag CI keeps recreating for every build of the staging branch.</summary>
public const string StagingTag = "staging";
private readonly HttpClient _http;
private readonly IDiagnosticsLog _log;
public GitHubReleaseFeed(IDiagnosticsLog log, Version current, HttpMessageHandler? handler = null)
{
_log = log;
_http = handler is null ? new HttpClient() : new HttpClient(handler);
_http.Timeout = TimeSpan.FromSeconds(10);
// The API turns away requests without a User-Agent.
_http.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("StarterNG", current.ToString()));
_http.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/vnd.github+json"));
}
public async Task<ReleaseLookup> LatestAsync(UpdateChannel channel, CancellationToken cancellationToken = default)
{
// "latest" is GitHub's own pick: the newest release that is not a pre-release.
string url = ReleasesUrl + (channel == UpdateChannel.Staging ? "tags/" + StagingTag : "latest");
try
{
using var response = await _http.GetAsync(url, cancellationToken);
// Nothing released yet.
if (response.StatusCode == HttpStatusCode.NotFound)
return ReleaseLookup.Found(null);
response.EnsureSuccessStatusCode();
return ReleaseLookup.Found(Parse(await response.Content.ReadAsStringAsync(cancellationToken), channel));
}
// Offline, rate limited or timed out: there is simply no answer this time,
// and a log entry on every start without a network would only be noise.
catch (HttpRequestException)
{
return ReleaseLookup.NoAnswer;
}
catch (TaskCanceledException)
{
return ReleaseLookup.NoAnswer;
}
catch (Exception ex)
{
_log.Log("update check", ex);
return ReleaseLookup.NoAnswer;
}
}
public static ReleaseInfo? Parse(string json, UpdateChannel channel)
{
var release = JsonSerializer.Deserialize(json, GitHubReleaseContext.Default.GitHubReleaseDocument);
if (release is null || release.Draft ||
string.IsNullOrEmpty(release.TagName) || string.IsNullOrEmpty(release.HtmlUrl))
return null;
bool belongs = channel == UpdateChannel.Staging
? release.TagName == StagingTag
: !release.Prerelease;
return belongs ? new ReleaseInfo(release.TagName, release.HtmlUrl, release.TargetCommitish) : null;
}
}
internal sealed class GitHubReleaseDocument
{
[JsonPropertyName("tag_name")] public string? TagName { get; set; }
[JsonPropertyName("html_url")] public string? HtmlUrl { get; set; }
[JsonPropertyName("target_commitish")] public string? TargetCommitish { get; set; }
[JsonPropertyName("draft")] public bool Draft { get; set; }
[JsonPropertyName("prerelease")] public bool Prerelease { get; set; }
}
[JsonSerializable(typeof(GitHubReleaseDocument))]
internal partial class GitHubReleaseContext : JsonSerializerContext
{
}

View File

@@ -53,9 +53,6 @@ public sealed class SettingsPaths
/// <summary>The sceneries starred in the list.</summary>
public string FavoritesPath() => Path.Combine(UserConfigDirectory(), "favorites.txt");
/// <summary>The day of the last update check and the release it found.</summary>
public string UpdateCheckPath() => Path.Combine(UserConfigDirectory(), "updatecheck.txt");
public string UserConfigDirectory() =>
Path.GetDirectoryName(UserConfigPath()) ?? _environment.BaseDirectory;
}

View File

@@ -57,11 +57,6 @@ public sealed class SettingsSerializer
s.VirtualShunting = c.GetBool("ai.trainman", true);
s.LogMissingVehicleFiles = c.GetBool("starter.logmissingvehicles", false);
s.DeveloperTools = c.GetBool("starter.developertools", false);
s.CheckForUpdates = c.GetBool("starter.checkupdates", true);
s.UpdateChannel = string.Equals(c.GetString("starter.updatechannel", "stable"), "staging",
StringComparison.OrdinalIgnoreCase)
? UpdateChannel.Staging
: UpdateChannel.Stable;
s.RenderEngine = IndexOf(SimulatorSettings.RenderEngines, c.GetString("gfxrenderer", "full"), 0);
s.Width = c.GetInt("width", 1280);
@@ -202,8 +197,6 @@ public sealed class SettingsSerializer
c.SetBool("ai.trainman", s.VirtualShunting);
c.SetBool("starter.logmissingvehicles", s.LogMissingVehicleFiles);
c.SetBool("starter.developertools", s.DeveloperTools);
c.SetBool("starter.checkupdates", s.CheckForUpdates);
c.Set("starter.updatechannel", s.UpdateChannel == UpdateChannel.Staging ? "staging" : "stable");
c.Set("gfxrenderer", SimulatorSettings.RenderEngines[Clamp(s.RenderEngine, 0, SimulatorSettings.RenderEngines.Length - 1)]);
c.SetInt("width", s.Width);