fix(app): build update links from the releases repository address
CI / Build and test (pull_request) Failing after 2m28s
CI / PostgreSQL 16 integration (pull_request) Skipped
CI / PostgreSQL 17 integration (pull_request) Skipped
CI / Docker image (pull_request) Skipped
CI / Windows tests and installer (pull_request) Skipped
CI / YAML check (pull_request) Successful in 10s

Gitea writes a release's html_url and browser_download_url with its ROOT_URL,
which on the owner's server is the plain-http LAN address
http://192.168.30.23:3000. The update check accepts only https links, so it
ignored v0.1.0-rc.1 entirely. The page and download links now come from
ChronosReleasesUrl, the address the build names for its users; only the
tags, file names and sizes are read from Gitea's answer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-10-23 14:08:10 +02:00
1 parent f2b58522b9
commit ee2d32f70f
6 files changed
+67 -16

No files matched your search

+2 -1
View File
@@ -1134,7 +1134,8 @@ for HEIC/RAW so the server can render without a node.
repository** (§19.4), `<server>/api/v1/repos/<owner>/<name>/releases?draft=false&pre-release=false`,
takes the highest version (a pre-release build is offered the final release of its own
version; a 404, a repository the client cannot see, is a failed check, not "up to date"),
and shows a one-line notice with "Download" (P1: download
builds the release page and download links from `ChronosReleasesUrl` (Gitea writes its own
with its ROOT_URL, which clients may not reach), and shows a one-line notice with "Download" (P1: download
installer, verify SHA-256 from `SHA256SUMS`, run it). The repository is the build
property `ChronosReleasesUrl` (default `https://gitea.encke-hake.ts.net/BalboSoft/Chronos`),
which also gives the licence link (`<repository>/src/branch/main/EULA.md`), the issues
+5
View File
@@ -5,6 +5,11 @@ commits follow Conventional Commits (release notes are generated from them by `C
## [Unreleased]
### Fixed
- Update check: the release page and the download links come from the repository address the build names
(`ChronosReleasesUrl`), not from Gitea's answer, whose links use Gitea's ROOT_URL; with the owner's plain-http LAN
ROOT_URL every release was ignored (the check accepts only https links).
## [0.1.0-rc.1] — 2026-10-23
First pre-release, built and published by Gitea Actions.
+1
View File
@@ -428,3 +428,4 @@ One line per decision: date · decision · alternative · reason.
| 2026-10-23 | The Windows-only CI (Core.Windows and App tests, screenshots and their diff, the installer test) is the `windows` job, run only when the repository variable `WINDOWS_RUNNER` names a Windows act_runner in host mode; until then those tests run on a Windows PC before a merge. The Definition of Done says so (CLAUDE.md, BRIEF Appendix A). (R3.) | Drop them; fail CI without a Windows runner | They are the only automatic proof of the installer and the screens; a job that waits for a runner that does not exist would hold every run. |
| 2026-10-23 | Update check: the client reads the published stable releases and takes the highest version, because Gitea's `releases/latest` is the most recently created release (a re-published older tag or a backport would become it); a pre-release build (`0.1.0-rc.1`) is offered the final release of its own version, which it used to call "up to date" forever; a 404 is a failed check, because Gitea answers 404 for a repository the client may not see (the `BalboSoft` organisation is private today) and that used to read as "up to date". The release workflow picks `:latest` the same way. `gitea-release` checks every file's size before it publishes, and when it replaces the files of a release clients can already see it removes the old `SHA256SUMS` first and uploads the new one last. (R2, R3; independent review of this change.) | Trust `releases/latest`; leave the pre-release rule as it was | The first release is a pre-release: its testers must be told when 0.1.0 is out; a download checked against the checksums of another build would be refused. |
| 2026-10-23 | Timed tests (bulk insert, JPEG and RAW decode, resampler, light analysis, metadata robustness, scroll smoke) take their budget from `TestTiming.Budget`, stretched by `CHRONOS_TEST_TIME_FACTOR` (at least 1, default 1); ci.yml and release.yml set 3, perf.yml nothing. On the owner's runner, which shares its CPU and disks with Gitea and the server's other containers, the 100k-frame SQLite bulk insert took 10–19 s against 15 s from one run to the next. (R3.) | Raise the budgets; move the timed tests to perf.yml | The budgets stay what a developer's PC must meet and the weekly performance gates measure them unstretched; a CI run fails on a real regression, not on a busy host. |
| 2026-10-23 | The update check builds the release page (`<repository>/releases/tag/<tag>`) and the download links (`<repository>/releases/download/<tag>/<name>`) from `ChronosReleasesUrl` and takes only the tags, names and sizes from Gitea's answer: Gitea writes `html_url` and `browser_download_url` with its ROOT_URL, the owner's being `http://192.168.30.23:3000`, so the first release's links were plain http on a LAN address and the https-only check ignored the release. Without a repository address (tests) the answer's links are used as before. (R2, after the first release.) | Ask the owner to set ROOT_URL to the public https name | The build already names the address its users reach; the client then works whatever Gitea's ROOT_URL is, and a ROOT_URL change stays the owner's choice. |
+33 -14
View File
@@ -16,7 +16,10 @@ public sealed record ReleaseAsset(string Name, string DownloadUrl, long Size);
/// <summary>
/// Update check against the Gitea releases API of the releases repository (BRIEF §18, §19.4, amended 2026-10-23, R2):
/// reads the published stable releases, takes the highest version (Gitea's own "latest" is the most recently created
/// one, which a re-published older tag or a backport would become), and compares it with the running version.
/// one, which a re-published older tag or a backport would become), and compares it with the running version. The
/// release page and download links are built from the repository address the build names (ChronosReleasesUrl), not
/// taken from the answer: Gitea writes its links with its ROOT_URL, which may be an address clients cannot reach
/// (the owner's is a plain-http LAN address).
/// </summary>
public static class UpdateCheck
{
@@ -35,30 +38,36 @@ public static class UpdateCheck
/// <summary>
/// The newest release of a releases-list response (an array: the highest version wins) or of one release object;
/// null when there is none. Drafts, pre-releases, unparsable tags and pages without an https link are skipped, and
/// so are assets without an https download link.
/// null when there is none. With <paramref name="repository"/> ("https://host/owner/name"), the release page and
/// the download links are that repository's (<c>/releases/tag/&lt;tag&gt;</c>, <c>/releases/download/&lt;tag&gt;/&lt;name&gt;</c>);
/// without it, the ones in the answer. Drafts, pre-releases, unparsable tags and pages without an https link are
/// skipped, and so are assets without an https download link.
/// </summary>
public static ReleaseInfo? Parse(string json)
public static ReleaseInfo? Parse(string json, string? repository = null)
{
var baseUrl = repository?.Trim().TrimEnd('/');
using var document = JsonDocument.Parse(json);
var root = document.RootElement;
return root.ValueKind switch
{
JsonValueKind.Array => root.EnumerateArray().Select(ParseRelease).OfType<ReleaseInfo>().MaxBy(r => r.Version),
JsonValueKind.Object => ParseRelease(root),
JsonValueKind.Array => root.EnumerateArray().Select(r => ParseRelease(r, baseUrl)).OfType<ReleaseInfo>().MaxBy(r => r.Version),
JsonValueKind.Object => ParseRelease(root, baseUrl),
_ => null,
};
}
private static ReleaseInfo? ParseRelease(JsonElement root)
private static ReleaseInfo? ParseRelease(JsonElement root, string? repository)
{
if (root.ValueKind != JsonValueKind.Object) return null;
if (Flag(root, "draft") || Flag(root, "prerelease")) return null;
var tag = root.TryGetProperty("tag_name", out var t) && t.ValueKind == JsonValueKind.String ? t.GetString() : null;
var url = root.TryGetProperty("html_url", out var u) && u.ValueKind == JsonValueKind.String ? u.GetString() : null;
var version = ParseVersion(tag);
if (version is null || tag is null || url is null || !url.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) return null;
return new ReleaseInfo(version, tag, url) { Assets = ParseAssets(root) };
if (version is null || tag is null) return null;
var url = repository is not null
? $"{repository}/releases/tag/{Uri.EscapeDataString(tag)}"
: root.TryGetProperty("html_url", out var u) && u.ValueKind == JsonValueKind.String ? u.GetString() : null;
if (url is null || !url.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) return null;
return new ReleaseInfo(version, tag, url) { Assets = ParseAssets(root, repository, tag) };
}
/// <summary>
@@ -91,7 +100,15 @@ public static class UpdateCheck
/// that is a failed check, never "up to date".
/// </summary>
/// <exception cref="HttpRequestException">The request failed, or the repository was not found.</exception>
public static async Task<ReleaseInfo?> FetchAsync(HttpClient http, string apiUrl, string userAgentVersion, CancellationToken ct)
public static Task<ReleaseInfo?> FetchAsync(HttpClient http, string apiUrl, string userAgentVersion, CancellationToken ct) =>
FetchAsync(http, apiUrl, null, userAgentVersion, ct);
/// <summary>
/// As <see cref="FetchAsync(HttpClient, string, string, CancellationToken)"/>, with the release page and download
/// links built from <paramref name="repository"/> (see <see cref="Parse"/>).
/// </summary>
/// <exception cref="HttpRequestException">The request failed, or the repository was not found.</exception>
public static async Task<ReleaseInfo?> FetchAsync(HttpClient http, string apiUrl, string? repository, string userAgentVersion, CancellationToken ct)
{
using var request = new HttpRequestMessage(HttpMethod.Get, apiUrl);
request.Headers.UserAgent.Add(new ProductInfoHeaderValue("Chronos", userAgentVersion));
@@ -103,7 +120,7 @@ public static class UpdateCheck
var json = await response.Content.ReadAsStringAsync(ct).ConfigureAwait(false);
try
{
return Parse(json);
return Parse(json, repository);
}
catch (JsonException)
{
@@ -111,7 +128,7 @@ public static class UpdateCheck
}
}
private static List<ReleaseAsset> ParseAssets(JsonElement root)
private static List<ReleaseAsset> ParseAssets(JsonElement root, string? repository, string tag)
{
var assets = new List<ReleaseAsset>();
if (!root.TryGetProperty("assets", out var list) || list.ValueKind != JsonValueKind.Array) return assets;
@@ -119,7 +136,9 @@ public static class UpdateCheck
{
if (a.ValueKind != JsonValueKind.Object) continue;
var name = a.TryGetProperty("name", out var n) && n.ValueKind == JsonValueKind.String ? n.GetString() : null;
var link = a.TryGetProperty("browser_download_url", out var d) && d.ValueKind == JsonValueKind.String ? d.GetString() : null;
var link = repository is not null && !string.IsNullOrEmpty(name)
? $"{repository}/releases/download/{Uri.EscapeDataString(tag)}/{Uri.EscapeDataString(name)}"
: a.TryGetProperty("browser_download_url", out var d) && d.ValueKind == JsonValueKind.String ? d.GetString() : null;
var size = a.TryGetProperty("size", out var z) && z.ValueKind == JsonValueKind.Number && z.TryGetInt64(out var bytes) ? bytes : -1;
if (string.IsNullOrEmpty(name) || link is null || !link.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) continue;
assets.Add(new ReleaseAsset(name, link, size));
@@ -71,7 +71,7 @@ public sealed class AppServices : IAsyncDisposable
Server = new ServerSession(settings, saveSettings, new ChronosServerApiFactory(), new DpapiTokenProtector());
Encoders = new MediaFoundationInventory();
Formats = new WicFormatInventory(() => _wic);
CheckForUpdateAsync = ct => UpdateCheck.FetchAsync(Http.Value, ProductLinks.StableReleasesApi, VersionText, ct);
CheckForUpdateAsync = ct => UpdateCheck.FetchAsync(Http.Value, ProductLinks.StableReleasesApi, ProductLinks.Repository, VersionText, ct);
DownloadUpdateAsync = (release, progress, ct) =>
UpdateDownload.DownloadAsync(DownloadHttp.Value, release, environment.IsPortable, UpdateDownload.Root(Path.GetTempPath()), VersionText, progress,
UpdateDownload.IdleTimeout, ct);
@@ -82,6 +82,31 @@ public sealed class UpdateCheckTests
await Assert.ThrowsAsync<HttpRequestException>(() => UpdateCheck.FetchAsync(broken, Api, "0.1.0", CancellationToken.None));
}
[Test]
public async Task LinksComeFromTheRepositoryAddressNotFromGiteasRootUrl()
{
// The owner's Gitea writes its links with its ROOT_URL, a plain-http LAN address clients cannot use.
const string json = """
[ { "tag_name": "v1.0.0", "html_url": "http://192.168.30.23:3000/BalboSoft/Chronos/releases/tag/v1.0.0",
"assets": [ { "name": "Chronos-Setup-1.0.0.exe", "size": 5, "browser_download_url": "http://192.168.30.23:3000/BalboSoft/Chronos/releases/download/v1.0.0/Chronos-Setup-1.0.0.exe" },
{ "name": "Read me.txt", "size": 2, "browser_download_url": "http://192.168.30.23:3000/x" } ] } ]
""";
Assert.Null(UpdateCheck.Parse(json));
var release = UpdateCheck.Parse(json, "https://gitea.example/BalboSoft/Chronos/")!;
Assert.Equal("https://gitea.example/BalboSoft/Chronos/releases/tag/v1.0.0", release.PageUrl);
Assert.SequenceEqual(
["https://gitea.example/BalboSoft/Chronos/releases/download/v1.0.0/Chronos-Setup-1.0.0.exe",
"https://gitea.example/BalboSoft/Chronos/releases/download/v1.0.0/Read%20me.txt"],
release.Assets.Select(a => a.DownloadUrl));
Assert.Equal(5L, release.Assets[0].Size);
Assert.Null(UpdateCheck.Parse(json, "http://gitea.example/BalboSoft/Chronos"));
using var ok = new HttpClient(new Reply(HttpStatusCode.OK, json));
var fetched = await UpdateCheck.FetchAsync(ok, Api, "https://gitea.example/BalboSoft/Chronos", "0.1.0", CancellationToken.None);
Assert.Equal("https://gitea.example/BalboSoft/Chronos/releases/tag/v1.0.0", fetched!.PageUrl);
}
[Test]
public async Task ARepositoryThatCannotBeSeenIsAFailedCheckNotUpToDate()
{