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

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:
Alby96andClaude Opus 5.5 authored and Alby96 committed 2026-10-23 12:45:18 +02:00
1 parent c99842cc86
commit f2b58522b9
1801 files changed
+11804 -10676

No files matched your search

+252
View File
@@ -0,0 +1,252 @@
using Chronos.App.Infrastructure;
using Chronos.Core.Archiving;
using Chronos.Core.Import;
using Chronos.Core.Localization;
using Chronos.Core.Naming;
namespace Chronos.App.Import;
/// <summary>Figures of a plan for the Plan panel header and the Import button (Import.html).</summary>
public sealed record PlanTotals(int Sessions, int Photos, int CopyCount, long CopyBytes, int Duplicates, int ImportedBefore, int Problems,
long? FreeAfter, TimeSpan Estimate)
{
public bool HasEnoughSpace => FreeAfter is not < 0;
/// <summary>"3 sessions · 4,812 photos · 96.2 GB · about 12 min".</summary>
public string Text => SummaryText + Loc.Separator + Loc.L("Import.Plan.About", Formatting.Duration(Estimate));
/// <summary>"3 sessions · 4,812 photos · 96.2 GB": the plan without its time estimate.</summary>
public string SummaryText => string.Join(Loc.Separator,
Loc.Plural("Import.Plan.Sessions", Sessions),
Loc.Plural("Shell.Status.Photos", Photos),
Formatting.Bytes(CopyBytes));
/// <summary>"0 duplicates" (already in the archive by hash).</summary>
public string DuplicatesText => Loc.Plural("Import.Plan.Duplicates", Duplicates);
/// <summary>"12 imported before" (same file from this card), or empty.</summary>
public string ImportedBeforeText => ImportedBefore > 0 ? Loc.Plural("Import.Plan.ImportedBefore", ImportedBefore) : string.Empty;
/// <summary>"2.1 TB free after import", "3.2 GB missing", or empty when the volume does not report its space.</summary>
public string SpaceText => FreeAfter switch
{
null => string.Empty,
< 0 => Loc.L("Import.Plan.SpaceMissing", Formatting.Bytes(-FreeAfter.Value)),
_ => Loc.L("Import.Plan.FreeAfter", Formatting.Bytes(FreeAfter.Value)),
};
/// <summary>"Import 4,812 photos".</summary>
public string ImportText => Loc.Plural("Import.Start", CopyCount);
}
/// <summary>One row of the session table: what the planner grouped and where it goes.</summary>
/// <param name="DefaultTitle">Title the sequence gets when the user types none (its folder name).</param>
/// <param name="IsNew">The session starts a new sequence (false: it continues one imported before).</param>
/// <param name="FirstPath">Card path of the session's first photo (where a merge joins it to the previous session).</param>
/// <param name="MergesInto">Number of the earlier session of the same camera and format it can merge into; null for none.</param>
public sealed record PlanSessionRow(int Number, string SessionKey, string? Title, string DefaultTitle, string TimeText, string FramesText,
string SizeText, string CameraText, string TargetText, bool IsNew, string FirstPath, int? MergesInto);
public enum PlanRowKind
{
Session,
File,
}
/// <summary>A line of "Show plan": a session heading and its folder, or one file (card path) and its destination path.</summary>
/// <param name="CanSplit">A file that is not the first of its session: a new session can start there.</param>
public sealed record PlanDetailRow(PlanRowKind Kind, string Source, string Destination, string ActionText, string SizeText, bool IsSkipped, bool CanSplit)
{
/// <summary>A file's name on the card (its session heading shows the rest); the heading itself for a session.</summary>
public string SourceText => Kind == PlanRowKind.File ? NameOf(Source) : Source;
/// <summary>The file's new name (its session shows the folder); the folder for a session.</summary>
public string DestinationText => Kind == PlanRowKind.File ? NameOf(Destination) : Destination;
/// <summary>"Split at IMG_0042.JPG": the row's split button as screen readers announce it.</summary>
public string SplitName => Loc.L("Import.Details.SplitName", SourceText);
private static string NameOf(string path) => path[(path.LastIndexOf('/') + 1)..];
}
/// <summary>Everything "Show plan" lists: every file to its destination, the totals and the conflicts.</summary>
public sealed record PlanDetails(IReadOnlyList<PlanDetailRow> Rows, string TotalsText, IReadOnlyList<string> Conflicts);
/// <summary>
/// Turns an <see cref="ImportPlan"/> into what the Import screen shows (BRIEF §12.4 "Plan before touching disk") and
/// applies the choices that need no new scan of the card: the duplicate choice and session titles.
/// </summary>
public static class ImportPlans
{
/// <summary>Planning speed assumption for the estimate: a UHS-I card read plus the read-back of the copy.</summary>
public const double BytesPerSecond = 80e6;
public const double VerifiedBytesPerSecond = 55e6;
public static TimeSpan Estimate(long bytes, bool verify) =>
TimeSpan.FromSeconds(System.Math.Ceiling(bytes / (verify ? VerifiedBytesPerSecond : BytesPerSecond)));
public static PlanTotals Totals(ImportPlan plan, bool verify) => new(
plan.Sessions.Count,
plan.FileCount,
plan.CopyCount,
plan.CopyBytes,
plan.Items.Count(i => i.ExistingFrameId is not null),
plan.Items.Count(i => i.Action == ImportAction.SkipImported),
plan.Problems.Count,
plan.AvailableBytes is { } free ? free - plan.CopyBytes : null,
Estimate(plan.CopyBytes, verify));
/// <summary>
/// The plan with every photo already in the archive skipped or imported again, as the planner would have decided
/// (BRIEF §13: skip, or import again; never overwrite).
/// </summary>
public static ImportPlan WithDuplicates(ImportPlan plan, DuplicatePolicy policy) => plan with
{
Sessions =
[
.. plan.Sessions.Select(s => s with
{
Items =
[
.. s.Items.Select(i => i.ExistingFrameId is null || i.Action == ImportAction.SkipImported
? i
: i with { Action = policy == DuplicatePolicy.Skip ? ImportAction.SkipInArchive : ImportAction.Copy }),
],
}),
],
};
/// <summary>The plan with the typed session titles (when no template uses <c>{title}</c>, so no name changes).</summary>
public static ImportPlan WithTitles(ImportPlan plan, IReadOnlyDictionary<string, string> titles) => plan with
{
Sessions = [.. plan.Sessions.Select(s => s with { Title = titles.TryGetValue(s.SessionKey, out var t) && !string.IsNullOrWhiteSpace(t) ? t.Trim() : null })],
};
/// <param name="existingFolders">Folders of sequences already in the archive (a session there continues it).</param>
public static IReadOnlyList<PlanSessionRow> Sessions(ImportPlan plan, ImportDestinationKind destination, IReadOnlySet<string> existingFolders) =>
[
.. plan.Sessions.Select(s =>
{
var isNew = !existingFolders.Contains(s.Folder);
var leaf = s.Folder[(s.Folder.LastIndexOf('/') + 1)..];
var target = destination switch
{
ImportDestinationKind.Server => Loc.L("Import.Session.Server"),
ImportDestinationKind.Folder => s.Folder,
_ => Loc.L(isNew ? "Import.Session.New" : "Import.Session.Adds", s.Folder),
};
return new PlanSessionRow(s.Number, s.SessionKey, s.Title, leaf, TimeText(s), FramesText(s), Formatting.Bytes(s.Items.Sum(i => i.Size)),
PathTemplate.CameraName(s.CameraMake, s.CameraModel), target, isNew, s.Items.Count > 0 ? s.Items[0].SourcePath : string.Empty,
MergeTarget(plan, s)?.Number);
}),
];
/// <summary>
/// The session <paramref name="session"/> joins when the user merges it (BRIEF §13): the one before it of the same
/// camera body and format, whose last photo precedes its first; sessions of other cameras or formats never merge.
/// </summary>
public static PlannedSession? MergeTarget(ImportPlan plan, PlannedSession session) =>
plan.Sessions.TakeWhile(s => !ReferenceEquals(s, session))
.LastOrDefault(s => s.CameraMake == session.CameraMake && s.CameraModel == session.CameraModel && s.CameraSerial == session.CameraSerial
&& s.Format == session.Format);
/// <summary>"Show plan": every file and where it goes, with the conflicts the plan resolved or reports.</summary>
public static PlanDetails Details(ImportPlan plan, ImportDestinationKind destination, bool verify)
{
var rows = new List<PlanDetailRow>(plan.FileCount + plan.Sessions.Count);
foreach (var s in plan.Sessions)
{
var folder = DestinationFolder(s, destination);
rows.Add(new PlanDetailRow(PlanRowKind.Session, Loc.L("Import.Details.Session", s.Number, TimeText(s)), folder,
Loc.Plural("Shell.Status.Photos", s.Items.Count), Formatting.Bytes(s.Items.Sum(i => i.Size)), false, false));
for (var i = 0; i < s.Items.Count; i++)
{
var item = s.Items[i];
rows.Add(new PlanDetailRow(PlanRowKind.File, item.SourcePath, folder + "/" + item.FileName, ActionText(item),
Formatting.Bytes(item.Size), item.Action != ImportAction.Copy, i > 0));
}
}
var totals = Totals(plan, verify);
var conflicts = new List<string>();
foreach (var problem in plan.Problems) conflicts.Add(Loc.L("Import.Details.Unreadable", BidiText.Ltr(problem.RelativePath), problem.Message));
if (totals.Duplicates > 0) conflicts.Add(totals.DuplicatesText);
if (!totals.HasEnoughSpace) conflicts.Add(totals.SpaceText);
var text = string.Join(Loc.Separator, new[]
{
Loc.Plural("Import.Details.Files", plan.FileCount),
Loc.L("Import.Details.Copy", Formatting.Count(plan.CopyCount), Formatting.Bytes(plan.CopyBytes)),
totals.ImportedBeforeText,
totals.Duplicates > 0 ? totals.DuplicatesText : string.Empty,
}.Where(t => t.Length > 0));
return new PlanDetails(rows, text, conflicts);
}
/// <summary>The destination of a session as the user will find it: the archive's originals folder, the folder, or the server.</summary>
public static string DestinationFolder(PlannedSession session, ImportDestinationKind destination) => destination switch
{
ImportDestinationKind.Archive => session.Folder + "/" + ArchiveLayout.OriginalsFolder,
ImportDestinationKind.Server => Loc.L("Import.Session.Server"),
_ => session.Folder,
};
/// <summary>The first <paramref name="count"/> files the plan copies, as folder/name (the name alone for the server).</summary>
public static IReadOnlyList<string> FirstDestinations(ImportPlan plan, ImportDestinationKind destination, int count = 3) =>
[
.. plan.Sessions.SelectMany(s => s.Items.Where(i => i.Action == ImportAction.Copy)
.Select(i => destination == ImportDestinationKind.Server ? i.FileName : s.Folder + "/" + i.FileName))
.Take(count),
];
/// <summary>
/// "→ 2026/2026-09-28 Canon EOS R5/2026-09-28_18-02-11_0001.CR2 · 2026-09-28_18-02-13_0002.CR2 · …" (BRIEF §7.1: the first
/// three names): a name in the same folder as the one before it is shown without the folder. Empty without names.
/// </summary>
public static string NamePreview(IReadOnlyList<string> paths)
{
if (paths.Count == 0) return string.Empty;
var shown = new List<string>(paths.Count);
for (var i = 0; i < paths.Count; i++)
{
var folder = FolderOf(paths[i]);
shown.Add(i > 0 && folder == FolderOf(paths[i - 1]) ? paths[i][(folder.Length == 0 ? 0 : folder.Length + 1)..] : paths[i]);
}
return Loc.L("Import.Names.Preview", string.Join(Loc.Separator, shown));
}
private static string FolderOf(string path) => path.LastIndexOf('/') is var slash and >= 0 ? path[..slash] : string.Empty;
private static string ActionText(PlannedItem item) => item.Action switch
{
ImportAction.SkipImported => Loc.L("Import.Action.ImportedBefore"),
ImportAction.SkipInArchive => Loc.L("Import.Action.Duplicate"),
_ when item.ExistingFrameId is not null => Loc.L("Import.Action.Again"),
_ => Loc.L("Import.Action.Copy"),
};
/// <summary>
/// "28/09/2026 · 18:02 → 20:04". Bidi never mirrors an arrow, so a right-to-left language reads it from its own
/// resource with the arrow pointing from the start to the end in its reading order.
/// </summary>
private static string TimeText(PlannedSession s) =>
Loc.L(Loc.IsRightToLeft ? "Import.Session.TimeRtl" : "Import.Session.Time", Formatting.Date(s.Start), s.Start.ToString("t", Loc.Culture),
s.End.ToString("t", Loc.Culture));
/// <summary>"3,600 · 2 s": photos and the median interval between them.</summary>
private static string FramesText(PlannedSession s)
{
var interval = MedianInterval(s.Items);
var count = Formatting.Count(s.Items.Count);
return interval is { } median ? Loc.L("Import.Session.Frames", count, Formatting.Duration(median)) : count;
}
internal static TimeSpan? MedianInterval(IReadOnlyList<PlannedItem> items)
{
if (items.Count < 2) return null;
var gaps = new List<double>(items.Count - 1);
for (var i = 1; i < items.Count; i++) gaps.Add((items[i].CapturedAt - items[i - 1].CapturedAt).TotalSeconds);
gaps.Sort();
var middle = gaps.Count / 2;
var seconds = gaps.Count % 2 == 1 ? gaps[middle] : (gaps[middle - 1] + gaps[middle]) / 2;
return TimeSpan.FromSeconds(System.Math.Max(0, seconds));
}
}