feat: single setup, mass-pass progress, per-server homes, Desktop shares its library (owner review 5, v1.1.0) (#68)
CI / Build and test (push) Successful in 11m36s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 12s
Release / Build, test and publish (push) Successful in 14m56s
CI / PostgreSQL 16 integration (push) Successful in 10m11s
CI / PostgreSQL 17 integration (push) Successful in 10m15s
CI / Docker image (push) Successful in 45s
Release / Server image (push) Successful in 4m55s
CI / Build and test (push) Successful in 11m36s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 12s
Release / Build, test and publish (push) Successful in 14m56s
CI / PostgreSQL 16 integration (push) Successful in 10m11s
CI / PostgreSQL 17 integration (push) Successful in 10m15s
CI / Docker image (push) Successful in 45s
Release / Server image (push) Successful in 4m55s
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #68.
This commit is contained in:
1 parent
988068ee8e
commit
20d64af4a4
793 files changed
+23882
-2096
No files matched your search
@@ -67,6 +67,8 @@ public sealed class DesktopScheduleHost(AppSettings settings, Func<ChronosDataba
|
||||
// The ages and the limit are Settings › Workspace's, read at each run: the schedule holds no days of its own.
|
||||
new(WorkspaceCleanup, "Workspace clean-up", ScheduleActions.Cleanup, ScheduleRecurrence.DailyAt(WorkspaceCleanupTime),
|
||||
new ScheduleParametersDto(Steps: [WorkspaceCleanStep.StepName, WorkspaceTrashStep.StepName], OlderThanDays: 0)),
|
||||
// While this PC shares its library (owner review 5, #67): the shared library's own clean-ups, which its Reset restores.
|
||||
.. settings.Share.Enabled ? Chronos.Server.Jobs.ServerScheduleHost.ShareSchedules(0) : [],
|
||||
];
|
||||
|
||||
public IReadOnlyList<string> CleanupSteps => archives()?.CleanupSteps.Select(s => s.Name).ToList() ?? [];
|
||||
@@ -84,7 +86,11 @@ public sealed class DesktopScheduleHost(AppSettings settings, Func<ChronosDataba
|
||||
public async ValueTask<Archive?> GetArchiveAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
if (database() is not { } db || archives() is not { } service) return null;
|
||||
var archive = CurrentArchive.Pick(await db.Archives.ListAsync(cancellationToken).ConfigureAwait(false), settings.LastArchivePath);
|
||||
var listed = await db.Archives.ListAsync(cancellationToken).ConfigureAwait(false);
|
||||
// Never a server's originals archive in place of this PC's (owner review 5): the app scans those after this one.
|
||||
var originals = settings.KnownServers.Select(k => k.OriginalsArchiveId).OfType<Guid>().ToHashSet();
|
||||
var archive = (settings.LastArchivePath is { Length: > 0 } last ? CurrentArchive.At(listed, last) : null)
|
||||
?? CurrentArchive.Pick([.. listed.Where(a => !originals.Contains(a.Id))], null) ?? CurrentArchive.Pick(listed, null);
|
||||
if (archive is null || ArchiveService.GetAvailability(archive) == ArchiveAvailability.Offline) return null;
|
||||
try
|
||||
{
|
||||
@@ -110,14 +116,15 @@ public sealed class DesktopScheduleHost(AppSettings settings, Func<ChronosDataba
|
||||
/// The desktop's clean-up step <c>cache-trim</c> (owner review 2, R10): brings the cache folder down to Settings › Storage ›
|
||||
/// Cache limit, oldest files first, skipping files in use (<see cref="CacheStore.Trim"/>). The proxies of server sequences
|
||||
/// (complete sets the sync keeps), the render node's folder (it trims its own downloads to the same limit) and the copies an
|
||||
/// import to the server stages are never trimmed; Settings › Storage › Clear still empties everything.
|
||||
/// import to the server stages are never trimmed, in the former shared folders and in each server's own (<c>servers</c>,
|
||||
/// owner review 5); Settings › Storage › Clear still empties everything.
|
||||
/// </summary>
|
||||
public sealed class CacheTrimStep(Func<string> folder, Func<long> limitBytes) : ICleanupStep
|
||||
{
|
||||
public const string StepName = "cache-trim";
|
||||
|
||||
/// <summary>Folders of the cache the trim leaves whole.</summary>
|
||||
public static IReadOnlyList<string> Kept { get; } = ["proxies", "render-node", "server-import"];
|
||||
public static IReadOnlyList<string> Kept { get; } = ["proxies", "render-node", "server-import", Chronos.Core.IO.HomeFolders.Servers];
|
||||
|
||||
public string Name => StepName;
|
||||
|
||||
|
||||
@@ -32,6 +32,12 @@ public sealed class JobEntry(Job job)
|
||||
public TimeSpan? Eta => Live?.Eta ?? Job.Eta;
|
||||
public string? Message => Live?.Message;
|
||||
|
||||
/// <summary>
|
||||
/// What the job does now (owner review 5, #65): the live detail while it runs, else the one stored with its last saved
|
||||
/// progress (where a paused or failed job stopped); null when its handler reports none.
|
||||
/// </summary>
|
||||
public JobDetail? Detail => Live?.Detail ?? Job.Detail;
|
||||
|
||||
/// <summary>0…1, or null while the total is unknown.</summary>
|
||||
public double? Fraction => Total > 0 ? Math.Clamp((double)Done / Total, 0, 1) : null;
|
||||
|
||||
|
||||
@@ -36,6 +36,17 @@ public sealed class JobRowViewModel : ObservableObject
|
||||
|
||||
public string Target => _entry.Job.TargetLabel ?? string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// What a running job does now, or where a paused or failed job stopped (owner review 5, #65), under the target; empty
|
||||
/// otherwise. Not announced: a screen reader hears state changes only (DECISIONS row 158).
|
||||
/// </summary>
|
||||
public string StatusText => JobText.RowStatus(_entry);
|
||||
|
||||
public bool HasStatus => StatusText.Length > 0;
|
||||
|
||||
/// <summary>The status line whole, then the speed and time left of a running job.</summary>
|
||||
public string StatusToolTip => JobText.RowStatusToolTip(_entry);
|
||||
|
||||
/// <summary>A schedule queued the job (owner review 2, R10): the row shows a "Scheduled" pill.</summary>
|
||||
public bool IsScheduled => _entry.Job.ScheduleId is not null;
|
||||
|
||||
@@ -136,6 +147,9 @@ public sealed class JobRowViewModel : ObservableObject
|
||||
return;
|
||||
}
|
||||
OnPropertyChanged(nameof(Progress));
|
||||
OnPropertyChanged(nameof(StatusText));
|
||||
OnPropertyChanged(nameof(HasStatus));
|
||||
OnPropertyChanged(nameof(StatusToolTip));
|
||||
OnPropertyChanged(nameof(PercentText));
|
||||
OnPropertyChanged(nameof(SpeedText));
|
||||
OnPropertyChanged(nameof(LeftText));
|
||||
|
||||
@@ -29,6 +29,141 @@ public static class JobText
|
||||
public static string Counter(long done, long total) =>
|
||||
total > 0 ? Loc.L("Jobs.Counter", Formatting.Count(done), Formatting.Count(total)) : string.Empty;
|
||||
|
||||
/// <summary>"1,240 / 3,600", or "52 GB / 1.1 TB" for a job that counts bytes; empty while the total is unknown.</summary>
|
||||
public static string Counter(JobKind kind, long done, long total) => total <= 0 ? string.Empty
|
||||
: CountsBytes(kind) ? Loc.L("Jobs.Counter", Formatting.Bytes(done), Formatting.Bytes(total))
|
||||
: Counter(done, total);
|
||||
|
||||
/// <summary>The longest status line the job bar shows (<see cref="Bar"/>); the item goes first, the full line is in the Jobs table.</summary>
|
||||
public const int BarStatusLength = 60;
|
||||
|
||||
/// <summary>
|
||||
/// What a job does now (owner review 5, #65), from its <paramref name="detail"/>: the step ("Verifying photo 812 of 2,400"),
|
||||
/// the item ("Harbour sunset", a folder kept left to right) and the part ("sequence 3 of 41"), each left out when empty;
|
||||
/// a clean-up or maintenance sub-step names itself in place of the step. A step this build does not know (a newer server)
|
||||
/// shows its counts only. Empty for no detail.
|
||||
/// </summary>
|
||||
public static string Status(JobDetail? detail) => Status(detail, int.MaxValue);
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="Status(JobDetail?)"/> in at most <paramref name="maxLength"/> characters: a longer line drops the item
|
||||
/// first, then is cut with an ellipsis.
|
||||
/// </summary>
|
||||
public static string Status(JobDetail? detail, int maxLength)
|
||||
{
|
||||
if (detail is null) return string.Empty;
|
||||
var (step, consumed) = StepPhrase(detail);
|
||||
var item = consumed ? null : ItemText(detail.Item);
|
||||
var part = PartPhrase(detail);
|
||||
var full = JoinParts(step, item, part);
|
||||
if (full.Length <= maxLength) return full;
|
||||
if (item is not null && JoinParts(step, null, part) is { Length: > 0 } shorter) full = shorter;
|
||||
return Cut(full, maxLength);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The status line of a Jobs row: what a running job does now; "Stopped at …" with where a paused or failed job stopped;
|
||||
/// empty for queued and finished jobs, and for a job whose handler reports no detail.
|
||||
/// </summary>
|
||||
public static string RowStatus(JobEntry entry)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(entry);
|
||||
return entry.State switch
|
||||
{
|
||||
JobState.Running => Status(entry.Detail),
|
||||
JobState.Paused or JobState.Failed when Status(entry.Job.Detail) is { Length: > 0 } status => Loc.L("Jobs.Detail.StoppedAt", status),
|
||||
_ => string.Empty,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>The tooltip of a row's status line: the line whole, then the speed and the time left while the job runs.</summary>
|
||||
public static string RowStatusToolTip(JobEntry entry)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(entry);
|
||||
var parts = new List<string>(3);
|
||||
if (RowStatus(entry) is { Length: > 0 } status) parts.Add(status);
|
||||
if (entry.State == JobState.Running)
|
||||
{
|
||||
if (Speed(entry.Job.Kind, entry.ItemsPerSecond) is { Length: > 0 } speed) parts.Add(speed);
|
||||
if (entry.Eta is { } eta) parts.Add(Loc.L("Jobs.Bar.Left", Formatting.Duration(eta)));
|
||||
}
|
||||
return string.Join(Loc.Separator, parts);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The step phrase, counted when the item is ("Verifying photo 812 of 2,400"), and whether it took the item's place (the
|
||||
/// named sub-step of a clean-up or maintenance).
|
||||
/// </summary>
|
||||
private static (string? Phrase, bool ConsumedItem) StepPhrase(JobDetail detail)
|
||||
{
|
||||
var counted = detail.ItemTotal > 0;
|
||||
var done = Formatting.Count(Math.Clamp(detail.ItemDone, 0, detail.ItemTotal));
|
||||
var total = Formatting.Count(detail.ItemTotal);
|
||||
var counts = counted ? Loc.L("Jobs.Detail.Count", done, total) : null;
|
||||
// A clean-up step ("job-history") and a maintenance step ("packs") name themselves.
|
||||
var named = detail.Step switch
|
||||
{
|
||||
JobStep.Cleanup => Known("Jobs.Schedule.Step." + Pascal(detail.Item)),
|
||||
JobStep.Maintenance => Known("Jobs.Maintenance.Step." + Pascal(detail.Item)),
|
||||
_ => null,
|
||||
};
|
||||
if (named is not null) return (JoinParts(Loc.L(named), counts, null), true);
|
||||
if (detail.Step == JobStep.None) return (counts, false);
|
||||
var key = "Jobs.Step." + detail.Step;
|
||||
// The item of a clean-up or maintenance step is a key, not data: one this build does not know is never shown.
|
||||
if (detail.Step is JobStep.Cleanup or JobStep.Maintenance) return (JoinParts(Known(key) is { } step ? Loc.L(step) : null, counts, null), true);
|
||||
if (counted && Known(key + ".Count") is { } countKey) return (Loc.L(countKey, done, total), false);
|
||||
if (Known(key) is null) return (counts, false);
|
||||
return (JoinParts(Loc.L(key), counts, null), false);
|
||||
}
|
||||
|
||||
/// <summary>"sequence 3 of 41" when the job has more than one part; null otherwise.</summary>
|
||||
private static string? PartPhrase(JobDetail detail)
|
||||
{
|
||||
if (detail.Parts <= 1) return null;
|
||||
var part = Formatting.Count(Math.Clamp(detail.Part, 0, detail.Parts));
|
||||
var parts = Formatting.Count(detail.Parts);
|
||||
return detail.PartUnit != JobPartUnit.None && Known("Jobs.Part." + detail.PartUnit) is { } key
|
||||
? Loc.L(key, part, parts)
|
||||
: Loc.L("Jobs.Detail.Count", part, parts);
|
||||
}
|
||||
|
||||
/// <summary>The item as data: a folder or a path kept left to right inside right-to-left text (DECISIONS row 218).</summary>
|
||||
private static string? ItemText(string? item)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(item)) return null;
|
||||
return item.Contains('/') || item.Contains('\\') ? Formatting.LeftToRight(item) : item;
|
||||
}
|
||||
|
||||
/// <summary>"job-history" → "JobHistory"; null for a key that is not one (data from a newer peer).</summary>
|
||||
private static string? Pascal(string? key)
|
||||
{
|
||||
if (string.IsNullOrEmpty(key) || key.Length > 40 || !key.All(c => char.IsAsciiLetterOrDigit(c) || c is '-' or '_')) return null;
|
||||
return string.Concat(key.Split('-', '_', StringSplitOptions.RemoveEmptyEntries).Select(p => char.ToUpperInvariant(p[0]) + p[1..]));
|
||||
}
|
||||
|
||||
/// <summary>The key when the catalog has it (the step, unit or sub-step of a newer peer may have none); null otherwise.</summary>
|
||||
private static string? Known(string? key) => key is not null && !key.EndsWith('.') && Loc.Get(key, Loc.Culture) is not null ? key : null;
|
||||
|
||||
private static string JoinParts(string? a, string? b, string? c)
|
||||
{
|
||||
var pieces = new List<string>(3);
|
||||
if (!string.IsNullOrEmpty(a)) pieces.Add(a);
|
||||
if (!string.IsNullOrEmpty(b)) pieces.Add(b);
|
||||
if (!string.IsNullOrEmpty(c)) pieces.Add(c);
|
||||
return string.Join(Loc.Separator, pieces);
|
||||
}
|
||||
|
||||
/// <summary>Cuts <paramref name="text"/> to <paramref name="max"/> characters with an ellipsis, closing a left-to-right island it cut into.</summary>
|
||||
private static string Cut(string text, int max)
|
||||
{
|
||||
if (text.Length <= max) return text;
|
||||
var length = Math.Max(1, max - 1);
|
||||
if (char.IsHighSurrogate(text[length - 1])) length--;
|
||||
var cut = text[..length] + "…";
|
||||
return cut.Count(c => c == '') > cut.Count(c => c == '') ? cut + "" : cut;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The "Left" column: time left while running, "after n" while queued, the finish time of the history.
|
||||
/// </summary>
|
||||
@@ -71,13 +206,22 @@ public static class JobText
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Job bar line (DESIGN §4): "Render · Harbour sunset · 2,232 / 3,600 · 11.3 fps · 2 min left".
|
||||
/// Job bar line (DESIGN §4): "Render · Harbour sunset · 2,232 / 3,600 · 11.3 fps · 2 min left"; with a detail, what the
|
||||
/// job does now in place of the counter ("Scan · Archive 2024 · Indexing photo 1,240 of 3,600 · folder 12 of 340 · 41/s ·
|
||||
/// 3 min left", at most <see cref="BarStatusLength"/> characters of it); a job that counts bytes shows sizes.
|
||||
/// </summary>
|
||||
public static string Bar(JobEntry entry)
|
||||
public static string Bar(JobEntry entry) => Bar(entry, BarStatusLength);
|
||||
|
||||
/// <summary>The job bar's tooltip: its line with what the job does now whole, the item (sequence, folder) included.</summary>
|
||||
public static string BarToolTip(JobEntry entry) => Bar(entry, int.MaxValue);
|
||||
|
||||
private static string Bar(JobEntry entry, int statusLength)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(entry);
|
||||
var parts = new List<string>(5) { Kind(entry.Job.Kind) };
|
||||
if (!string.IsNullOrWhiteSpace(entry.Job.TargetLabel)) parts.Add(entry.Job.TargetLabel!);
|
||||
if (Counter(entry.Done, entry.Total) is { Length: > 0 } counter) parts.Add(counter);
|
||||
if (Status(entry.Detail, statusLength) is { Length: > 0 } status) parts.Add(status);
|
||||
else if (Counter(entry.Job.Kind, entry.Done, entry.Total) is { Length: > 0 } counter) parts.Add(counter);
|
||||
if (Speed(entry.Job.Kind, entry.ItemsPerSecond) is { Length: > 0 } speed) parts.Add(speed);
|
||||
if (entry.Eta is { } eta) parts.Add(Loc.L("Jobs.Bar.Left", Formatting.Duration(eta)));
|
||||
return string.Join(Loc.Separator, parts);
|
||||
|
||||
Reference in new issue
Block a user