feat: owner review 2 phase 5c: originals, local render, clean-up and the workspace settings (#18)
CI / Build and test (push) Successful in 9m26s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 8s
Release / Build, test and publish (push) Successful in 14m31s
CI / PostgreSQL 16 integration (push) Successful in 9m53s
CI / PostgreSQL 17 integration (push) Successful in 9m22s
CI / Docker image (push) Successful in 44s
Release / Server image (push) Successful in 1m36s
CI / Build and test (push) Successful in 9m26s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 8s
Release / Build, test and publish (push) Successful in 14m31s
CI / PostgreSQL 16 integration (push) Successful in 9m53s
CI / PostgreSQL 17 integration (push) Successful in 9m22s
CI / Docker image (push) Successful in 44s
Release / Server image (push) Successful in 1m36s
Originals in the workspace, local render and send home with provenance, the workspace clean-up, size limit and trash, moving the workspace folder, and the complete Settings › Workspace page (owner review 2, R8, phase 5c). One adversarial review round (35 findings, 32 fixed), a copy-cancel race fixed, 184 strings in all 38 languages. 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 #18.
This commit is contained in:
1 parent
81c303f484
commit
db389a54f2
364 files changed
+17417
-595
No files matched your search
@@ -20,8 +20,8 @@ namespace Chronos.App.Jobs;
|
||||
/// wrote into its archive.json, as the rescans before it did, and counts as none while it is offline (an unplugged
|
||||
/// drive). The system schedules stand for the timers the desktop used to run out of sight: the archive scan (its interval
|
||||
/// carried over from the former Settings › Archive › Rescan every, <see cref="AppSettings.ScanIntervalMinutes"/>, once:
|
||||
/// a row that exists keeps the user's edits), the daily index backup, and the housekeeping clean-up at 04:00 (job history,
|
||||
/// cache trim). Scans give what they find a deep analysis as Settings › Analysis › After a scan says at each run
|
||||
/// a row that exists keeps the user's edits), the daily index backup, the housekeeping clean-up at 04:00 (job history,
|
||||
/// cache trim), and the workspace's clean-up at 04:30 (phase 5c: its media, a report of its trash). Scans give what they find a deep analysis as Settings › Analysis › After a scan says at each run
|
||||
/// (<see cref="DeepAnalysisAfterScan"/>), like the scans started by hand. Thread-safe: the scheduler calls it from its loop.
|
||||
/// </summary>
|
||||
public sealed class DesktopScheduleHost(AppSettings settings, Func<ChronosDatabase?> database, Func<ArchiveService?> archives) : IScheduleHost
|
||||
@@ -41,6 +41,16 @@ public sealed class DesktopScheduleHost(AppSettings settings, Func<ChronosDataba
|
||||
/// <summary>When the housekeeping runs.</summary>
|
||||
public static readonly TimeOnly HousekeepingTime = new(4, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Clean-up of the workspace (phase 5c), daily at 04:30, with catch-up: the media of projects past Settings › Workspace ›
|
||||
/// Clean after or Size limit (<see cref="WorkspaceCleanStep"/>), and a report of its trash (<see cref="WorkspaceTrashStep"/>),
|
||||
/// which it never empties. It runs whether an archive is open or not.
|
||||
/// </summary>
|
||||
public const string WorkspaceCleanup = "workspace-cleanup";
|
||||
|
||||
/// <summary>When the workspace clean-up runs: after the housekeeping.</summary>
|
||||
public static readonly TimeOnly WorkspaceCleanupTime = new(4, 30);
|
||||
|
||||
/// <summary>The PC's zone; tests set another.</summary>
|
||||
public TimeZoneInfo TimeZone { get; init; } = TimeZoneInfo.Local;
|
||||
|
||||
@@ -54,6 +64,9 @@ public sealed class DesktopScheduleHost(AppSettings settings, Func<ChronosDataba
|
||||
new(Housekeeping, "Housekeeping", ScheduleActions.Cleanup, ScheduleRecurrence.DailyAt(HousekeepingTime),
|
||||
new ScheduleParametersDto(Steps: [Chronos.Data.Housekeeping.CleanupSteps.JobHistory, CacheTrimStep.StepName],
|
||||
OlderThanDays: Chronos.Data.Housekeeping.CleanupSteps.DefaultHistoryDays)),
|
||||
// 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)),
|
||||
];
|
||||
|
||||
public IReadOnlyList<string> CleanupSteps => archives()?.CleanupSteps.Select(s => s.Name).ToList() ?? [];
|
||||
|
||||
@@ -40,7 +40,8 @@ public static class JobNotices
|
||||
|
||||
private static bool Announces(JobKind kind) =>
|
||||
kind is JobKind.Render or JobKind.DeepAnalyse or JobKind.Verify or JobKind.Rebuild or JobKind.Maintenance or JobKind.UploadCommit
|
||||
or JobKind.Move or JobKind.Adopt or JobKind.EmptyTrash or JobKind.Convert;
|
||||
or JobKind.Move or JobKind.Adopt or JobKind.EmptyTrash or JobKind.Convert or JobKind.WorkspaceRender or JobKind.WorkspaceSend
|
||||
or JobKind.WorkspaceMove;
|
||||
|
||||
/// <summary>
|
||||
/// Work that keeps the index and its previews current: the next run repeats it, the Archive screen shows what is missing.
|
||||
|
||||
@@ -12,7 +12,7 @@ public static class JobText
|
||||
|
||||
/// <summary>True for jobs whose items are frames, so their speed reads in fps.</summary>
|
||||
public static bool CountsFrames(JobKind kind) =>
|
||||
kind is JobKind.Render or JobKind.Proxies or JobKind.Thumbs or JobKind.DeepAnalyse;
|
||||
kind is JobKind.Render or JobKind.Proxies or JobKind.Thumbs or JobKind.DeepAnalyse or JobKind.WorkspaceRender;
|
||||
|
||||
/// <summary>True for jobs whose progress counts bytes (hash verification, card import).</summary>
|
||||
public static bool CountsBytes(JobKind kind) => kind is JobKind.Verify or JobKind.Import;
|
||||
|
||||
@@ -166,6 +166,7 @@ public static class ScheduleText
|
||||
DesktopScheduleHost.ArchiveScan => "Jobs.Schedule.System.ArchiveScan",
|
||||
DesktopScheduleHost.IndexBackup => "Jobs.Schedule.System.IndexBackup",
|
||||
DesktopScheduleHost.Housekeeping => "Jobs.Schedule.System.Housekeeping",
|
||||
DesktopScheduleHost.WorkspaceCleanup => "Jobs.Schedule.System.WorkspaceCleanup",
|
||||
_ => null,
|
||||
};
|
||||
|
||||
@@ -175,6 +176,8 @@ public static class ScheduleText
|
||||
CleanupSteps.Audit => "Audit",
|
||||
CleanupSteps.TrashReport => "TrashReport",
|
||||
CacheTrimStep.StepName => "CacheTrim",
|
||||
WorkspaceCleanStep.StepName => "WorkspaceClean",
|
||||
WorkspaceTrashStep.StepName => "WorkspaceTrash",
|
||||
_ => null,
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
using Chronos.App.Infrastructure;
|
||||
using Chronos.App.Workspace;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Data.Archiving.Jobs;
|
||||
using Chronos.Data.Housekeeping;
|
||||
using Chronos.Data.Workspaces;
|
||||
|
||||
namespace Chronos.App.Jobs;
|
||||
|
||||
/// <summary>
|
||||
/// The desktop's clean-up step <c>workspace-clean</c> (phase 5c): removes the media of workspace projects in step with their
|
||||
/// home, those not opened for Settings › Workspace › Clean after, then the least recently used while the projects take more
|
||||
/// than Size limit (<see cref="WorkspaceHost.CleanAsync"/>). Each project kept is logged with why. It needs no archive: the
|
||||
/// <c>workspace-cleanup</c> schedule runs it whether one is open or not. The trash is never emptied here.
|
||||
/// </summary>
|
||||
public sealed class WorkspaceCleanStep(Func<WorkspaceHost?> workspace) : ICleanupStep
|
||||
{
|
||||
public const string StepName = "workspace-clean";
|
||||
|
||||
public string Name => StepName;
|
||||
|
||||
public async Task<string> RunAsync(CleanupContext context, CleanupParameters parameters)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(context);
|
||||
if (workspace() is not { } host || await host.CleanAsync(cleanAfter: true, cancellationToken: context.Cancellation).ConfigureAwait(false) is not { } report)
|
||||
return Loc.L("Jobs.Log.WorkspaceUnavailable");
|
||||
foreach (var kept in report.Kept)
|
||||
context.Job.Log(Loc.L("Jobs.Log.WorkspaceKept", Named(kept.SequenceTitle, kept.Name, kept.IsMain), Reason(kept.Reason)));
|
||||
if (report.Cleaned.Count == 0 && report.Kept.Count == 0) return Loc.L("Jobs.Log.WorkspaceNothing", Formatting.Bytes(report.UsedBefore));
|
||||
foreach (var cleaned in report.Cleaned.Where(c => c.Trashed > 0))
|
||||
context.Job.Log(Loc.L("Archive.Log.WorkspaceOriginalsTrashed", Named(cleaned.SequenceTitle, cleaned.Name, cleaned.IsMain), Formatting.Count(cleaned.Trashed)));
|
||||
return Loc.L("Jobs.Log.WorkspaceCleaned", Formatting.Count(report.Cleaned.Count), Formatting.Bytes(report.Freed), Formatting.Count(report.Kept.Count));
|
||||
}
|
||||
|
||||
/// <summary>"open in Edit", "renders not sent", …: why a project was kept, for the job log.</summary>
|
||||
public static string Reason(WorkspaceKeep reason) => Loc.L("Jobs.Log.WorkspaceSkip." + reason);
|
||||
|
||||
/// <summary>"Harbour sunset · Main": a project as the job log names it (its sequence, then its name).</summary>
|
||||
public static string Named(string sequenceTitle, string name, bool isMain)
|
||||
{
|
||||
var project = WorkspaceText.ProjectName(name, isMain);
|
||||
return sequenceTitle is { Length: > 0 } title ? title + Loc.Separator + project : project;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The desktop's clean-up step <c>workspace-trash</c> (phase 5c): reports what the workspace's trash holds (entries and
|
||||
/// size); it never deletes, emptying it stays the user's Settings › Workspace › Trash › Empty….
|
||||
/// </summary>
|
||||
public sealed class WorkspaceTrashStep(Func<WorkspaceHost?> workspace) : ICleanupStep
|
||||
{
|
||||
public const string StepName = "workspace-trash";
|
||||
|
||||
public string Name => StepName;
|
||||
|
||||
public async Task<string> RunAsync(CleanupContext context, CleanupParameters parameters)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(context);
|
||||
if (workspace() is not { IsEnabled: true } host) return Loc.L("Jobs.Log.WorkspaceUnavailable");
|
||||
var plan = await host.PlanTrashAsync(context.Cancellation).ConfigureAwait(false);
|
||||
return Loc.L("Jobs.Log.WorkspaceTrash", Formatting.Count(plan.Items.Count), Formatting.Bytes(plan.Bytes));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user