refactor!: rename Titano to Chronos and move CI and releases to Gitea (#6)
CI / Build and test (push) Successful in 8m14s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 13m19s
CI / PostgreSQL 16 integration (push) Successful in 4m49s
CI / PostgreSQL 17 integration (push) Successful in 5m28s
CI / Docker image (push) Successful in 53s
Release / Server image (push) Failing after 10s
CI / Build and test (push) Successful in 8m14s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 13m19s
CI / PostgreSQL 16 integration (push) Successful in 4m49s
CI / PostgreSQL 17 integration (push) Successful in 5m28s
CI / Docker image (push) Successful in 53s
Release / Server image (push) Failing after 10s
The owner renamed the product and moved the repository to the self-hosted Gitea (https://gitea.encke-hake.ts.net/BalboSoft/Chronos) for more control, and asked for Actions and a first automatic release with the server package and the Windows exe (docs/requests/2026-10-23-chronos-gitea.md). - Chronos everywhere: a byte-exact rename of contents and paths, then a per-language review of the forms the old name's ending had dictated. - Gitea instead of GitHub: the update check, licence, issue and support links read ChronosReleasesUrl; the update check takes the highest stable version, offers a pre-release build its final release and reports a repository it cannot see as a failed check. EULA, security policy and Gitea issue forms live at the repository root. - Gitea Actions for the Linux act_runner (.gitea/workflows): CI, release, nightly image and performance gates in the .NET SDK container with git checkout and the system SQLite. The release cross-compiles the Windows programs, checks their icon, version and DPI manifest, packs installers and zips, publishes the Gitea release and pushes the server image (REGISTRY_TOKEN). Windows-only tests run in an opt-in job on a Windows runner (WINDOWS_RUNNER). - New Chronos.Tools commands: zip, gitea-release, postgres-ci (replaces the docker-exec script, which Gitea's service containers do not allow; the throw-away server runs without durability) and pe-check. - Timed tests take their budget from TestTiming (CHRONOS_TEST_TIME_FACTOR, 3 on the shared runner; the weekly performance gates keep theirs). BREAKING CHANGE: programs, settings, data folders, file types, environment variables and the Docker image use the new name; nothing is migrated from Titano, which never had a release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #6.
This commit is contained in:
1 parent
c99842cc86
commit
f2b58522b9
1801 files changed
+11804
-10676
No files matched your search
@@ -0,0 +1,137 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Chronos.Core.Archiving;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Core.Naming;
|
||||
using Chronos.Data;
|
||||
using Chronos.Data.Archiving;
|
||||
using Chronos.Data.Jobs;
|
||||
using Chronos.Data.Repositories;
|
||||
using Chronos.Protocol;
|
||||
using Chronos.Server.Jobs;
|
||||
using Chronos.Server.Security;
|
||||
using Chronos.Server.Storage;
|
||||
|
||||
namespace Chronos.Server.Api;
|
||||
|
||||
/// <summary><c>/api/v1/archive</c> (admin): templates and proxy policy, scan/rebuild/verify/maintenance jobs, statistics.</summary>
|
||||
public static class ArchiveEndpoints
|
||||
{
|
||||
public static void Map(RouteGroupBuilder api)
|
||||
{
|
||||
var archive = api.MapGroup("/archive").Requires(Permissions.ManageArchive);
|
||||
// The form saves every field: it starts from what archive.json holds now, also a desktop's change since the last poll.
|
||||
archive.MapGet("/settings", async (HttpContext c, ServerArchive a, ChronosDatabase db, [FromServices] ArchiveService? archives) =>
|
||||
Results.Json(Settings(archives is null ? a.Current : await a.RefreshAsync(archives, db, c.RequestAborted)), ProtocolJson.Default.ArchiveSettingsDto));
|
||||
archive.MapPut("/settings", UpdateAsync);
|
||||
archive.MapGet("/stats", async (HttpContext c, ChronosDatabase db, ServerArchive a) =>
|
||||
Results.Json(await StatsAsync(db, a, c.RequestAborted), ProtocolJson.Default.ArchiveStatsDto));
|
||||
foreach (var (path, kind) in new[] { ("scan", JobKind.Scan), ("rebuild", JobKind.Rebuild), ("verify", JobKind.Verify), ("maintenance", JobKind.Maintenance) })
|
||||
{
|
||||
archive.MapPost("/" + path, (HttpContext c, Caller caller, ServerArchive a, JobEngineHost host, AuditLog audit) => EnqueueAsync(c, caller, a, host, audit, kind));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Totals, distributions, free space and health of the archive (also shown on the dashboard).</summary>
|
||||
public static async Task<ArchiveStatsDto> StatsAsync(ChronosDatabase db, ServerArchive archive, CancellationToken cancellationToken)
|
||||
{
|
||||
var stats = await db.Sequences.GetStatsAsync(archive.Id, cancellationToken);
|
||||
var withoutProxies = await db.Sequences.CountAsync(
|
||||
new SequenceQuery { ArchiveId = archive.Id, WithoutStatus = SequenceStatus.ProxiesBuilt }, cancellationToken);
|
||||
long free = 0, capacity = 0;
|
||||
try
|
||||
{
|
||||
var drive = new DriveInfo(archive.Root);
|
||||
free = drive.AvailableFreeSpace;
|
||||
capacity = drive.TotalSize;
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or ArgumentException or UnauthorizedAccessException)
|
||||
{
|
||||
// An offline archive volume reports no space figures.
|
||||
}
|
||||
return new ArchiveStatsDto(
|
||||
stats.Sequences,
|
||||
stats.Photos,
|
||||
stats.Bytes,
|
||||
free,
|
||||
capacity,
|
||||
stats.ByCamera.Count(c => c.Model is not null),
|
||||
stats.ByYear.Count > 0 ? stats.ByYear[0].Year : null,
|
||||
stats.ByYear.Count > 0 ? stats.ByYear[^1].Year : null,
|
||||
[.. stats.ByYear.Select(y => new KeyValueCount(y.Year.ToString(System.Globalization.CultureInfo.InvariantCulture), y.Photos, y.Bytes))],
|
||||
[.. stats.ByMonth.Select(m => new KeyValueCount($"{m.Year:D4}-{m.Month:D2}", m.Photos, 0))],
|
||||
[.. stats.ByCamera.Select(c => new KeyValueCount(string.Join(' ', new[] { c.Make, c.Model }.Where(v => !string.IsNullOrEmpty(v))), c.Photos, c.Bytes))],
|
||||
[.. stats.ByFormat.Select(f => new KeyValueCount(f.Format.ToString().ToLowerInvariant(), f.Photos, f.Bytes))],
|
||||
withoutProxies,
|
||||
stats.Health.Unverified);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the name, templates and proxy policy into the archive's <c>archive.json</c> through the archive engine (so a
|
||||
/// restart and the proxy jobs see them), then into the index. 503 <c>archive_offline</c> while the archive cannot be
|
||||
/// written; 409 <c>archive_busy</c> while another process holds its settings; 409 <c>archive_manifest</c> when its
|
||||
/// archive.json is damaged, written by a newer Chronos or of another archive; 409 <c>archive_policy</c> when it holds a
|
||||
/// thumbnail or proxy setting this API cannot set and Chronos cannot use (details: <c>thumbnailPolicy</c> or
|
||||
/// <c>proxyPolicy</c>, the property to correct in the file). Nothing is written.
|
||||
/// </summary>
|
||||
private static async Task<IResult> UpdateAsync(HttpContext context, Caller caller, ArchiveSettingsDto request, ChronosDatabase db, ServerArchive archive,
|
||||
[FromServices] ArchiveService? archives, AuditLog audit)
|
||||
{
|
||||
var name = request.Name?.Trim();
|
||||
if (string.IsNullOrEmpty(name) || name.Length > ArchiveSettings.MaxNameLength) return ApiErrors.BadRequest(context, "bad_request", "name");
|
||||
foreach (var (field, template) in new[] { ("folderTemplate", request.FolderTemplate), ("fileTemplate", request.FileTemplate) })
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(template) || !PathTemplate.Parse(template).IsValid) return ApiErrors.BadRequest(context, "invalid_template", field);
|
||||
}
|
||||
if (!ProxyPolicy.IsValidLongEdge(request.ProxyLongEdge)) return ApiErrors.BadRequest(context, "bad_request", "proxyLongEdge");
|
||||
|
||||
var engine = archives ?? new ArchiveService(db, new ArchiveServiceOptions { Owner = ArchiveModule.Owner });
|
||||
Archive updated;
|
||||
try
|
||||
{
|
||||
updated = await engine.UpdateSettingsAsync(archive.Id, s => s with
|
||||
{
|
||||
Name = name,
|
||||
Templates = s.Templates with { Folder = request.FolderTemplate, File = request.FileTemplate },
|
||||
Proxies = s.Proxies with { LongEdge = request.ProxyLongEdge },
|
||||
}, context.RequestAborted);
|
||||
}
|
||||
catch (LeaseUnavailableException)
|
||||
{
|
||||
return ApiErrors.Conflict(context, "archive_busy");
|
||||
}
|
||||
catch (Exception ex) when (ex is InvalidDataException or NewerFormatException)
|
||||
{
|
||||
return ApiErrors.Conflict(context, "archive_manifest");
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
// The request's fields were checked above: what fails is a value read from archive.json (a thumbnail size, or a
|
||||
// proxy quality, written by hand or by another tool), which the admin corrects in the file, not in this form.
|
||||
return ApiErrors.Conflict(context, "archive_policy", ex.ParamName switch
|
||||
{
|
||||
"thumbnailLongEdge" => "thumbnailPolicy",
|
||||
"proxyLongEdge" => "proxyPolicy",
|
||||
var other => other,
|
||||
});
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
|
||||
{
|
||||
// ArchiveOfflineException included: nothing was written.
|
||||
return ApiErrors.Result(context, StatusCodes.Status503ServiceUnavailable, "archive_offline");
|
||||
}
|
||||
archive.Current = updated;
|
||||
await audit.WriteAsync(caller, context, "archive_settings", "archive", updated.Id.ToString(), $"{updated.FolderTemplate} · {updated.FileTemplate}");
|
||||
return Results.Json(Settings(updated), ProtocolJson.Default.ArchiveSettingsDto);
|
||||
}
|
||||
|
||||
private static async Task<IResult> EnqueueAsync(HttpContext context, Caller caller, ServerArchive archive, JobEngineHost host, AuditLog audit, JobKind kind)
|
||||
{
|
||||
if (!host.CanRun(kind)) return ApiErrors.Conflict(context, "job_unavailable", JobWire.Kind(kind));
|
||||
var job = await host.Engine.EnqueueAsync(kind, [archive.Id], archive.Current.Name, priority: JobPriority.User, createdBy: caller.Id,
|
||||
cancellationToken: context.RequestAborted);
|
||||
await audit.WriteAsync(caller, context, "job_created", "job", job.Id.ToString(), JobWire.Kind(kind));
|
||||
return Results.Json(Dto.Job(job), ProtocolJson.Default.JobDto, statusCode: StatusCodes.Status202Accepted);
|
||||
}
|
||||
|
||||
private static ArchiveSettingsDto Settings(Archive a) => new(a.Id, a.Name, a.RootPath, a.FolderTemplate, a.FileTemplate, a.ProxyLongEdge);
|
||||
}
|
||||
Reference in new issue
Block a user