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,429 @@
|
||||
using System.IO;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
using Chronos.App.Infrastructure;
|
||||
using Chronos.App.Settings;
|
||||
using Chronos.Core.Archiving;
|
||||
using Chronos.Core.Diagnostics;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Data;
|
||||
using Chronos.Data.Archiving;
|
||||
using Chronos.Ui.Mvvm;
|
||||
|
||||
namespace Chronos.App.Archiving;
|
||||
|
||||
/// <summary>
|
||||
/// An in-window dialog of the Archive screen: one primary action, one way out. While its action runs, the way out
|
||||
/// stops it when it can be stopped, and is disabled otherwise; the close callback receives the dialog, so a late close
|
||||
/// never closes another one. A failure stays on screen as one sentence until the next attempt.
|
||||
/// </summary>
|
||||
public abstract class ArchiveDialogViewModel : LocalizedViewModel
|
||||
{
|
||||
private readonly Action<ArchiveDialogViewModel> _close;
|
||||
private bool _isBusy;
|
||||
private string? _busyText;
|
||||
private string? _errorText;
|
||||
private string? _errorToolTip;
|
||||
|
||||
protected ArchiveDialogViewModel(Action<ArchiveDialogViewModel> close)
|
||||
{
|
||||
_close = close;
|
||||
CloseCommand = new RelayCommand(() =>
|
||||
{
|
||||
if (IsBusy) Stop();
|
||||
else Close();
|
||||
}, () => !IsBusy || CanStop);
|
||||
}
|
||||
|
||||
/// <summary>Cancel: closes the dialog, or stops its running action.</summary>
|
||||
public ICommand CloseCommand { get; }
|
||||
|
||||
public string CloseToolTip => !IsBusy ? Loc.L("Tooltips.Archive.CloseDialog")
|
||||
: CanStop ? Loc.L("Tooltips.Archive.StopApply")
|
||||
: Loc.L("Archive.Blocked.Applying");
|
||||
|
||||
/// <summary>The running action can stop between two steps.</summary>
|
||||
protected virtual bool CanStop => false;
|
||||
|
||||
protected virtual void Stop()
|
||||
{
|
||||
}
|
||||
|
||||
public bool IsBusy
|
||||
{
|
||||
get => _isBusy;
|
||||
protected set
|
||||
{
|
||||
if (!Set(ref _isBusy, value)) return;
|
||||
OnPropertyChanged(nameof(CloseToolTip));
|
||||
CommandManager.InvalidateRequerySuggested();
|
||||
}
|
||||
}
|
||||
|
||||
public string? BusyText { get => _busyText; protected set => Set(ref _busyText, value); }
|
||||
|
||||
/// <summary>Why the last dry run or apply stopped (<see cref="ArchiveFailures.Cause"/>); null when nothing failed.</summary>
|
||||
public string? ErrorText { get => _errorText; private set => Set(ref _errorText, value); }
|
||||
|
||||
/// <summary>The failure as the engine reported it, for the tooltip.</summary>
|
||||
public string? ErrorToolTip { get => _errorToolTip; private set => Set(ref _errorToolTip, value); }
|
||||
|
||||
protected void Close() => _close(this);
|
||||
|
||||
protected void ShowError(Exception ex)
|
||||
{
|
||||
ErrorText = ArchiveFailures.Cause(ex);
|
||||
ErrorToolTip = ex.Message;
|
||||
}
|
||||
|
||||
protected void ClearError()
|
||||
{
|
||||
ErrorText = null;
|
||||
ErrorToolTip = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A fact of the rebuild dialog ("Sidecars · 412"); a path stays left to right, a missing value says why in its tooltip.</summary>
|
||||
public sealed record DialogFact(string Label, string Value, bool IsPath = false, string? Reason = null)
|
||||
{
|
||||
public string ToolTip => Reason ?? Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// "Rebuild index" (BRIEF §12.5): what the rebuild reads — the sidecars on disk, then a full metadata scan of folders
|
||||
/// without one — next to what the index holds now. Originals are never touched; the rebuild runs as a job.
|
||||
/// </summary>
|
||||
public sealed class RebuildDialogViewModel : ArchiveDialogViewModel
|
||||
{
|
||||
private readonly Func<Task> _rebuild;
|
||||
private IReadOnlyList<DialogFact> _facts;
|
||||
|
||||
public RebuildDialogViewModel(Core.Model.Archive archive, ArchiveAvailability availability, int indexed, Func<Task> rebuild,
|
||||
Action<ArchiveDialogViewModel> close)
|
||||
: base(close)
|
||||
{
|
||||
_rebuild = rebuild;
|
||||
Archive = archive;
|
||||
Availability = availability;
|
||||
Indexed = indexed;
|
||||
_facts = Facts(null, availability == ArchiveAvailability.Offline ? Loc.L("Archive.Error.Offline", Formatting.LeftToRight(archive.RootPath)) : null);
|
||||
RebuildCommand = new AsyncRelayCommand(RebuildAsync, () => !IsBusy && availability == ArchiveAvailability.Online);
|
||||
}
|
||||
|
||||
public Core.Model.Archive Archive { get; }
|
||||
public ArchiveAvailability Availability { get; }
|
||||
public int Indexed { get; }
|
||||
|
||||
public IReadOnlyList<DialogFact> FactRows { get => _facts; private set => Set(ref _facts, value); }
|
||||
|
||||
public ICommand RebuildCommand { get; }
|
||||
|
||||
public string RebuildToolTip => Availability == ArchiveAvailability.Online ? Loc.L("Tooltips.Archive.RebuildStart") : Loc.L("Archive.Blocked.NotOnline");
|
||||
|
||||
/// <summary>
|
||||
/// Counts sequence folders with and without a sidecar (a walk of the archive tree, off the UI thread). The counts
|
||||
/// read "Counting…" only while the walk runs; an offline archive or a failed walk leaves "—" with the reason.
|
||||
/// </summary>
|
||||
public async Task CountAsync()
|
||||
{
|
||||
if (Availability == ArchiveAvailability.Offline) return;
|
||||
BusyText = Loc.L("Archive.Rebuild.Counting");
|
||||
try
|
||||
{
|
||||
var root = Archive.RootPath;
|
||||
var folders = await Task.Run(() => ArchiveScanner.FindSequenceFolders(new ArchivePaths(root)));
|
||||
FactRows = Facts(folders, null);
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
|
||||
{
|
||||
Log.Warning("archive", "Counting sidecars failed", ex);
|
||||
FactRows = Facts(null, ArchiveFailures.Cause(ex));
|
||||
}
|
||||
finally
|
||||
{
|
||||
BusyText = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Shows counts computed elsewhere (capture).</summary>
|
||||
public void ShowFolders(IReadOnlyList<SequenceFolder> folders) => FactRows = Facts(folders, null);
|
||||
|
||||
/// <param name="folders">The counted folders; null while counting or when they cannot be counted.</param>
|
||||
/// <param name="uncounted">Why the folders cannot be counted; null while counting.</param>
|
||||
private IReadOnlyList<DialogFact> Facts(IReadOnlyList<SequenceFolder>? folders, string? uncounted)
|
||||
{
|
||||
DialogFact Count(string label, Func<SequenceFolder, bool> counted) =>
|
||||
folders is not null ? new(label, Formatting.Count(folders.Count(counted)))
|
||||
: uncounted is not null ? new(label, "—", Reason: uncounted)
|
||||
: new(label, Loc.L("Archive.Rebuild.Counting"));
|
||||
return
|
||||
[
|
||||
new(Loc.L("Archive.Rebuild.Archive"), Archive.Name),
|
||||
new(Loc.L("Archive.Rebuild.Root"), Archive.RootPath, IsPath: true),
|
||||
new(Loc.L("Archive.Rebuild.State"), Loc.L("Archive.Availability." + Availability)),
|
||||
new(Loc.L("Archive.Rebuild.Indexed"), Loc.Plural("Shell.Status.Sequences", Indexed)),
|
||||
Count(Loc.L("Archive.Rebuild.Sidecars"), f => f.Sidecar is not null),
|
||||
Count(Loc.L("Archive.Rebuild.Metadata"), f => f.Sidecar is null),
|
||||
];
|
||||
}
|
||||
|
||||
private async Task RebuildAsync()
|
||||
{
|
||||
IsBusy = true;
|
||||
try
|
||||
{
|
||||
await _rebuild();
|
||||
Close();
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsBusy = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mass rename (titles) or move (folder layout) of a set (BRIEF §7, §12.5): the template is checked as it is typed,
|
||||
/// the dry run lists every change, and Apply makes exactly those changes (journaled, so a crash resumes it).
|
||||
/// </summary>
|
||||
public sealed class RenameDialogViewModel : ArchiveDialogViewModel
|
||||
{
|
||||
private readonly ArchiveService _archives;
|
||||
private readonly Core.Model.Archive _archive;
|
||||
private readonly IReadOnlyList<Sequence> _set;
|
||||
private readonly Func<int, Task> _applied;
|
||||
private readonly DispatcherTimer _delay = new() { Interval = TimeSpan.FromMilliseconds(400) };
|
||||
private RenamePlan? _plan;
|
||||
private string? _planError;
|
||||
private IReadOnlyList<RenameRow> _rows = [];
|
||||
private CancellationTokenSource? _planning;
|
||||
|
||||
public RenameDialogViewModel(RenameMode mode, ArchiveService archives, Core.Model.Archive archive, IReadOnlyList<Sequence> set, Func<int, Task> applied,
|
||||
Action<ArchiveDialogViewModel> close)
|
||||
: base(close)
|
||||
{
|
||||
Mode = mode;
|
||||
_archives = archives;
|
||||
_archive = archive;
|
||||
_set = set;
|
||||
_applied = applied;
|
||||
var initial = mode == RenameMode.Folders ? archive.FolderTemplate : "{title}";
|
||||
Template = new EditableField(initial, t => MassRename.Validate(mode, t), committed => _ = PlanAsync(),
|
||||
() => Loc.L(mode == RenameMode.Folders ? "Tooltips.Archive.FolderTemplate" : "Tooltips.Archive.TitleTemplate"));
|
||||
Template.PropertyChanged += (_, e) =>
|
||||
{
|
||||
if (e.PropertyName != nameof(EditableField.Text)) return;
|
||||
_delay.Stop();
|
||||
_delay.Start();
|
||||
};
|
||||
_delay.Tick += (_, _) =>
|
||||
{
|
||||
_delay.Stop();
|
||||
_ = PlanAsync();
|
||||
};
|
||||
ApplyCommand = new AsyncRelayCommand(ApplyAsync, () => ApplyBlocker is null);
|
||||
}
|
||||
|
||||
/// <summary>Why Apply is disabled; null when it can run.</summary>
|
||||
private string? ApplyBlocker =>
|
||||
IsBusy ? Loc.L("Archive.Blocked.Applying")
|
||||
: Template.Error is { } error ? error
|
||||
: _plan is null ? _planError ?? Loc.L("Archive.Blocked.Planning")
|
||||
: _plan.Steps.Count == 0 ? Loc.L("Archive.Blocked.NoChanges")
|
||||
: null;
|
||||
|
||||
public string ApplyToolTip => ApplyBlocker ?? Loc.L("Tooltips.Archive.RenameApply");
|
||||
|
||||
public RenameMode Mode { get; }
|
||||
|
||||
public string Heading => Loc.Plural(Mode == RenameMode.Folders ? "Archive.Rename.MoveHeading" : "Archive.Rename.Heading", _set.Count);
|
||||
|
||||
public EditableField Template { get; }
|
||||
|
||||
public IReadOnlyList<RenameRow> Rows { get => _rows; private set => Set(ref _rows, value); }
|
||||
|
||||
public string SummaryText => _plan is null ? string.Empty : MassRename.Summary(_plan, _set.Count);
|
||||
|
||||
public ICommand ApplyCommand { get; }
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
_delay.Stop();
|
||||
_planning?.Cancel();
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The dry run of the current template (the engine's plan; nothing changes on disk); it clears the last failure and
|
||||
/// stands in for a dry run still waiting on typing, which would otherwise throw this plan away.
|
||||
/// </summary>
|
||||
public Task PlanAsync()
|
||||
{
|
||||
_delay.Stop();
|
||||
ClearError();
|
||||
return DryRunAsync();
|
||||
}
|
||||
|
||||
private async Task DryRunAsync()
|
||||
{
|
||||
_planning?.Cancel();
|
||||
_plan = null;
|
||||
_planError = null;
|
||||
Rows = [];
|
||||
OnPlanChanged();
|
||||
if (Template.HasErrors) return;
|
||||
var cts = _planning = new CancellationTokenSource();
|
||||
var template = Template.Text;
|
||||
var ids = _set.Select(s => s.Id).ToList();
|
||||
try
|
||||
{
|
||||
var plan = await Task.Run(() => _archives.PlanRenameAsync(_archive.Id, ids, Mode == RenameMode.Folders ? template : null,
|
||||
Mode == RenameMode.Titles ? template : null, cts.Token), cts.Token);
|
||||
if (cts.IsCancellationRequested) return;
|
||||
_plan = plan;
|
||||
Rows = MassRename.Rows(plan, Mode);
|
||||
}
|
||||
catch (OperationCanceledException) when (cts.IsCancellationRequested)
|
||||
{
|
||||
return;
|
||||
}
|
||||
catch (Exception ex) when (ex is ArgumentException or DatabaseException or FormatException)
|
||||
{
|
||||
Log.Warning("archive", "Rename plan failed", ex);
|
||||
_planError = ArchiveFailures.Cause(ex);
|
||||
ShowError(ex);
|
||||
}
|
||||
OnPlanChanged();
|
||||
}
|
||||
|
||||
private void OnPlanChanged()
|
||||
{
|
||||
OnPropertyChanged(nameof(SummaryText));
|
||||
OnPropertyChanged(nameof(ApplyToolTip));
|
||||
CommandManager.InvalidateRequerySuggested();
|
||||
}
|
||||
|
||||
private async Task ApplyAsync()
|
||||
{
|
||||
if (_plan is not { } plan) return;
|
||||
ClearError();
|
||||
IsBusy = true;
|
||||
// A tick posted before the apply ended must not bring its progress back.
|
||||
var progress = new Progress<int>(n =>
|
||||
{
|
||||
if (IsBusy) BusyText = Loc.L("Archive.Rename.Applying", Formatting.Count(n), Formatting.Count(plan.Steps.Count));
|
||||
});
|
||||
try
|
||||
{
|
||||
await Task.Run(() => _archives.ApplyRenameAsync(plan, progress));
|
||||
Log.Info("archive", $"{Mode} applied to {plan.Steps.Count} sequence(s)");
|
||||
await _applied(plan.Steps.Count);
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or StaleRenamePlanException or DatabaseException)
|
||||
{
|
||||
Log.Warning("archive", "Rename failed", ex);
|
||||
ShowError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsBusy = false;
|
||||
BusyText = null;
|
||||
}
|
||||
// Part of the plan may have been applied, or the archive changed under it: the dry run shows what is left.
|
||||
await DryRunAsync();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Add and remove tags on a set (BRIEF §12.5 Retag): the dry run counts the sequences that change.</summary>
|
||||
public sealed class RetagDialogViewModel : ArchiveDialogViewModel
|
||||
{
|
||||
private readonly ArchiveService _archives;
|
||||
private readonly IReadOnlyList<Sequence> _set;
|
||||
private readonly Func<int, Task> _applied;
|
||||
private CancellationTokenSource? _run;
|
||||
|
||||
public RetagDialogViewModel(ArchiveService archives, IReadOnlyList<Sequence> set, Func<int, Task> applied, Action<ArchiveDialogViewModel> close)
|
||||
: base(close)
|
||||
{
|
||||
_archives = archives;
|
||||
_set = set;
|
||||
_applied = applied;
|
||||
Add = new EditableField(string.Empty, Retag.Validate, _ => OnPropertyChanged(nameof(SummaryText)), () => Loc.L("Tooltips.Archive.TagsAdd"));
|
||||
Remove = new EditableField(string.Empty, Retag.Validate, _ => OnPropertyChanged(nameof(SummaryText)), () => Loc.L("Tooltips.Archive.TagsRemove"));
|
||||
Add.PropertyChanged += (_, _) => OnTagsTyped();
|
||||
Remove.PropertyChanged += (_, _) => OnTagsTyped();
|
||||
ApplyCommand = new AsyncRelayCommand(ApplyAsync, () => ApplyBlocker is null);
|
||||
}
|
||||
|
||||
/// <summary>Why Apply is disabled; null when it can run.</summary>
|
||||
private string? ApplyBlocker =>
|
||||
IsBusy ? Loc.L("Archive.Blocked.Applying")
|
||||
: Add.Error ?? Remove.Error
|
||||
?? (Changes().Count == 0 ? Loc.L("Archive.Blocked.NoChanges") : null);
|
||||
|
||||
public string ApplyToolTip => ApplyBlocker ?? Loc.L("Tooltips.Archive.RetagApply");
|
||||
|
||||
public string Heading => Loc.Plural("Archive.Retag.Heading", _set.Count);
|
||||
|
||||
public EditableField Add { get; }
|
||||
public EditableField Remove { get; }
|
||||
|
||||
/// <summary>"12 of 36 change".</summary>
|
||||
public string SummaryText => Loc.Plural("Archive.Rename.Summary", Changes().Count, _set.Count);
|
||||
|
||||
public ICommand ApplyCommand { get; }
|
||||
|
||||
/// <summary>Typing changes the dry run, and with it whether Apply can run.</summary>
|
||||
private void OnTagsTyped()
|
||||
{
|
||||
OnPropertyChanged(nameof(SummaryText));
|
||||
OnPropertyChanged(nameof(ApplyToolTip));
|
||||
CommandManager.InvalidateRequerySuggested();
|
||||
}
|
||||
|
||||
private IReadOnlyList<(Sequence Sequence, IReadOnlyList<string> Tags)> Changes() =>
|
||||
Add.HasErrors || Remove.HasErrors ? [] : Retag.Changes(_set, Retag.Parse(Add.Text), Retag.Parse(Remove.Text));
|
||||
|
||||
protected override bool CanStop => _run is not null;
|
||||
|
||||
/// <summary>Stops after the sequence being written; each sequence is changed completely or not at all.</summary>
|
||||
protected override void Stop() => _run?.Cancel();
|
||||
|
||||
private async Task ApplyAsync()
|
||||
{
|
||||
var changes = Changes();
|
||||
var (add, remove) = (Retag.Parse(Add.Text), Retag.Parse(Remove.Text));
|
||||
var run = _run = new CancellationTokenSource();
|
||||
var done = 0;
|
||||
ClearError();
|
||||
IsBusy = true;
|
||||
try
|
||||
{
|
||||
for (; done < changes.Count && !run.IsCancellationRequested; done++)
|
||||
{
|
||||
var id = changes[done].Sequence.Id;
|
||||
BusyText = Loc.L("Archive.Rename.Applying", Formatting.Count(done + 1), Formatting.Count(changes.Count));
|
||||
// The tags as they are now (the set may predate an edit or a sync); title, rating and notes stay untouched.
|
||||
await Task.Run(() => _archives.EditSequenceInfoAsync(id, info => info with { Tags = Retag.Apply(info.Tags, add, remove) }));
|
||||
}
|
||||
Log.Info("archive", $"Retag: {done} of {changes.Count} sequence(s) changed");
|
||||
await _applied(done);
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or ArgumentException or DatabaseException)
|
||||
{
|
||||
Log.Warning("archive", "Retag failed", ex);
|
||||
ShowError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_run = null;
|
||||
run.Dispose();
|
||||
IsBusy = false;
|
||||
BusyText = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user