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
@@ -178,15 +178,29 @@ public sealed class AppServices : IAsyncDisposable
|
||||
typeof(AppServices).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? "0.0.0";
|
||||
|
||||
/// <summary>The job handlers of this PC's engine — the single registration list; a kind without a handler stays
|
||||
/// queued (it is never claimed here). The workspace copy is the desktop's alone: it writes into this PC's workspace, from
|
||||
/// this PC's archive or, through the signed-in session, from a server.</summary>
|
||||
/// queued (it is never claimed here). The workspace's jobs are the desktop's alone: they write into this PC's workspace
|
||||
/// (a copy from this PC's archive or, through the signed-in session, from a server; a local render with this PC's
|
||||
/// encoders; the sending of its renders home; the move of its folder, which Settings › Workspace then names).</summary>
|
||||
public static IReadOnlyList<IJobHandler> CreateJobHandlers(AppServices services) =>
|
||||
[
|
||||
.. services.Archives?.CreateJobHandlers() ?? [], .. services.Processing?.CreateJobHandlers() ?? [],
|
||||
.. services.Sync.Service?.CreateJobHandlers(services.Sync) ?? [],
|
||||
.. services.Database is { } db && services.Archives is { } archives ? WorkspaceJobs.CreateHandlers(db, archives, services.Sync) : [],
|
||||
.. services.Database is { } db && services.Archives is { } archives
|
||||
? WorkspaceJobs.CreateHandlers(db, archives, services.Sync, WorkspaceOptions(services, archives))
|
||||
: [],
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// The workspace jobs' share of the desktop (phase 5c): its processing options for local renders, the metered hold of
|
||||
/// Settings › Server over transfers with a server, the workspace that follows a moved folder, and the folder in use
|
||||
/// (a job queued before a move finds its project there).
|
||||
/// </summary>
|
||||
private static WorkspaceJobOptions WorkspaceOptions(AppServices services, ArchiveService archives) =>
|
||||
new(services.Processing?.Options ?? WorkspaceJobOptions.For(archives).Processing,
|
||||
() => services.Settings.PauseUploadsOnMetered && MeteredNetwork.IsMetered(),
|
||||
services.Workspace.MovedAsync,
|
||||
() => services.Workspace.Root);
|
||||
|
||||
/// <summary>
|
||||
/// Queues a scan of <paramref name="archive"/> unless one is already waiting or running; the sequences it indexes get
|
||||
/// a background deep analysis when Settings › Analysis asks for it.
|
||||
@@ -469,7 +483,9 @@ public sealed class AppServices : IAsyncDisposable
|
||||
Parallelism = () => Parallelism,
|
||||
MemoryBudget = () => ProcessingTuning.MemoryBudget(Settings, GC.GetGCMemoryInfo().TotalAvailableMemoryBytes),
|
||||
// The housekeeping schedule trims the cache to Settings › Storage › Cache limit (owner review 2, R10).
|
||||
CleanupSteps = [new CacheTrimStep(() => CacheStore.Folder(Environment, Settings), () => Settings.CacheLimitGb * (1L << 30))],
|
||||
// The workspace-cleanup schedule removes the media past Settings › Workspace's Clean after and Size limit, and reports its trash (phase 5c).
|
||||
CleanupSteps = [new CacheTrimStep(() => CacheStore.Folder(Environment, Settings), () => Settings.CacheLimitGb * (1L << 30)),
|
||||
new WorkspaceCleanStep(() => Workspace), new WorkspaceTrashStep(() => Workspace)],
|
||||
BackupDirectory = Environment.BackupDirectory,
|
||||
// Told after each step of a Reorganize, and each sequence a conversion replaced or made, while the rest of the job runs.
|
||||
SequenceChanged = (id, _, _) =>
|
||||
@@ -485,6 +501,8 @@ public sealed class AppServices : IAsyncDisposable
|
||||
var kinds = handlers.Select(h => h.Kind).Distinct().ToArray();
|
||||
// One job at a time (owner review 1): the parallelism works inside it, the priority queue decides which runs.
|
||||
Engine = new JobEngine(database, handlers, new JobEngineOptions { WorkerId = WorkerId, Kinds = kinds, PriorityQueue = () => PriorityQueue });
|
||||
// The workspace's size limit runs after each copy of media into it (phase 5c).
|
||||
Engine.JobChanged += Workspace.OnJobChanged;
|
||||
// Sync follows the engine's jobs before it runs any: a render resumed at start that finishes at once is still sent (Export "Sync").
|
||||
Sync.Update();
|
||||
// With no handler the engine must not run: an empty kind list would let workers claim (and fail) every job.
|
||||
|
||||
@@ -7,6 +7,7 @@ using Chronos.Core.Diagnostics;
|
||||
using Chronos.Core.Import;
|
||||
using Chronos.Core.IO;
|
||||
using Chronos.Core.Naming;
|
||||
using Chronos.Core.Project;
|
||||
using Chronos.Data.Archiving;
|
||||
using Chronos.Data.Repositories;
|
||||
using Chronos.Ui.Theming;
|
||||
@@ -39,6 +40,21 @@ public enum HardwarePreference
|
||||
HardwareForPreviews,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Which project Edit opens for a sequence that has several in the workspace (Settings › Workspace › Open project, phase 5c).
|
||||
/// </summary>
|
||||
public enum WorkspaceOpenPolicy
|
||||
{
|
||||
/// <summary>The project opened last for the sequence (<see cref="AppSettings.WorkspaceRecent"/>), else the one saved last.</summary>
|
||||
LastUsed,
|
||||
|
||||
/// <summary>The sequence's Main project.</summary>
|
||||
Main,
|
||||
|
||||
/// <summary>Ask each time, listing the sequence's projects.</summary>
|
||||
Ask,
|
||||
}
|
||||
|
||||
/// <summary>A server certificate the user trusted on first use (BRIEF §12.7).</summary>
|
||||
public sealed class TrustedCertificate
|
||||
{
|
||||
@@ -58,6 +74,8 @@ public sealed class AppSettings
|
||||
public const int DefaultCacheLimitGb = 20;
|
||||
public const int DefaultScanIntervalMinutes = 10;
|
||||
public const int DefaultWorkspaceKeptVersions = 20;
|
||||
public const int DefaultWorkspaceSizeLimitGb = 100;
|
||||
public const int DefaultWorkspaceCleanAfterDays = 30;
|
||||
|
||||
/// <summary>2⁻⁴ of white: the deep analysis' night threshold (a mean log2 luminance of −4).</summary>
|
||||
public const double DefaultNightBrightnessPercent = 6.25;
|
||||
@@ -169,6 +187,48 @@ public sealed class AppSettings
|
||||
/// <summary>The workspace project opened last for each sequence (sequence id → project id); Edit opens it again.</summary>
|
||||
public Dictionary<Guid, Guid> WorkspaceRecent { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Phase 5c: past this size (GB of 2³⁰ bytes) the workspace's clean-up removes the media of the projects used longest ago
|
||||
/// that are in step with their home (never one open, with jobs, or with renders not sent); 0 = no limit.
|
||||
/// </summary>
|
||||
public int WorkspaceSizeLimitGb { get; set; } = DefaultWorkspaceSizeLimitGb;
|
||||
|
||||
/// <summary>
|
||||
/// What "Open in workspace" copies unless chosen otherwise: <see cref="BundleMedia.Proxies"/> or
|
||||
/// <see cref="BundleMedia.Originals"/> (the proxies plus the originals, to render on this PC).
|
||||
/// </summary>
|
||||
public string WorkspaceDefaultMedia { get; set; } = BundleMedia.Proxies;
|
||||
|
||||
/// <summary>A render of a project with changes not saved as a version saves one first (and sends it when Sync automatically is on).</summary>
|
||||
public bool WorkspaceVersionOnRender { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// The workspace's clean-up removes the media of a project not opened for this many days, once it is in step with its
|
||||
/// home; 0 = never.
|
||||
/// </summary>
|
||||
public int WorkspaceCleanAfterDays { get; set; } = DefaultWorkspaceCleanAfterDays;
|
||||
|
||||
/// <summary>Which project Edit opens for a sequence with several in the workspace.</summary>
|
||||
public WorkspaceOpenPolicy WorkspaceOpenProject { get; set; } = WorkspaceOpenPolicy.LastUsed;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="WorkspaceDefaultMedia"/> as everything applies it: the originals for any case of "originals", else the
|
||||
/// proxies (a value set elsewhere reads as the proxies). Settings › Workspace shows the same.
|
||||
/// </summary>
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public string EffectiveDefaultMedia =>
|
||||
string.Equals(WorkspaceDefaultMedia, BundleMedia.Originals, StringComparison.OrdinalIgnoreCase) ? BundleMedia.Originals : BundleMedia.Proxies;
|
||||
|
||||
/// <summary><see cref="WorkspaceOpenProject"/> as everything applies it: a value this Chronos does not know reads as the last used. Settings › Workspace shows the same.</summary>
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public WorkspaceOpenPolicy EffectiveOpenPolicy => Enum.IsDefined(WorkspaceOpenProject) ? WorkspaceOpenProject : WorkspaceOpenPolicy.LastUsed;
|
||||
|
||||
/// <summary>
|
||||
/// When each workspace project was last opened in Edit (project id → time), which the clean-up goes by (else the time
|
||||
/// its working state was saved). This PC's, like <see cref="WorkspaceRecent"/>.
|
||||
/// </summary>
|
||||
public Dictionary<Guid, DateTimeOffset> WorkspaceOpened { get; set; } = [];
|
||||
|
||||
// ---- Server ----
|
||||
public string? ServerUrl { get; set; }
|
||||
public string? ServerUsername { get; set; }
|
||||
@@ -188,7 +248,7 @@ public sealed class AppSettings
|
||||
/// <summary>Send and take project settings changed on one side without asking (Server.html).</summary>
|
||||
public bool SyncSettingsAutomatically { get; set; } = true;
|
||||
|
||||
/// <summary>Pause upload jobs while Windows reports the connection as metered (Server.html).</summary>
|
||||
/// <summary>Pause transfers with a server (uploads, sync downloads, workspace copies and renders sent) while Windows reports the connection as metered (Server.html).</summary>
|
||||
public bool PauseUploadsOnMetered { get; set; }
|
||||
|
||||
// ---- Jobs ----
|
||||
@@ -285,6 +345,64 @@ public sealed class AppSettings
|
||||
|
||||
/// <summary>A deep copy (JSON round trip), used for import and reset.</summary>
|
||||
public AppSettings Clone() => Parse(ToJson()) ?? new AppSettings();
|
||||
|
||||
/// <summary>
|
||||
/// Settings › Advanced › Reset: every default, but the values that are this PC's or this user's state rather than
|
||||
/// preferences: the archive and the session, the window and its rail, the sequence edited last, the first-run flag, the
|
||||
/// jobs cleared, and the workspace (its folder, moved only by its own operation, the projects opened last and when).
|
||||
/// </summary>
|
||||
public AppSettings ResetKeepingState() => new()
|
||||
{
|
||||
LastArchivePath = LastArchivePath,
|
||||
ServerUrl = ServerUrl,
|
||||
ServerUsername = ServerUsername,
|
||||
ProtectedToken = ProtectedToken,
|
||||
TrustedCertificates = TrustedCertificates,
|
||||
RecentServers = RecentServers,
|
||||
Window = Window,
|
||||
RailCollapsed = RailCollapsed,
|
||||
LastEditedSequence = LastEditedSequence,
|
||||
FirstRunCompleted = FirstRunCompleted,
|
||||
JobsClearedAt = JobsClearedAt,
|
||||
WorkspaceFolder = WorkspaceFolder,
|
||||
WorkspaceRecent = WorkspaceRecent,
|
||||
WorkspaceOpened = WorkspaceOpened,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Settings › Export: a copy without secrets and machine-bound values (the session, the window, the workspace's folder and
|
||||
/// what it remembers of its projects: another PC's ids mean nothing there).
|
||||
/// </summary>
|
||||
public AppSettings ForExport()
|
||||
{
|
||||
var copy = Clone();
|
||||
copy.ProtectedToken = null;
|
||||
copy.Window = null;
|
||||
copy.WorkspaceFolder = null;
|
||||
copy.WorkspaceRecent = [];
|
||||
copy.WorkspaceOpened = [];
|
||||
return copy;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Settings › Import: <paramref name="imported"/> with this PC's own values taken from these settings: the session, the
|
||||
/// window and its rail, the sequence edited last, the first-run flag, and the workspace (its folder, the projects opened
|
||||
/// last and when). Changes and returns <paramref name="imported"/>.
|
||||
/// </summary>
|
||||
public AppSettings KeepLocalIn(AppSettings imported)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(imported);
|
||||
imported.ProtectedToken = ProtectedToken;
|
||||
imported.ServerUrl = ServerUrl;
|
||||
imported.Window = Window;
|
||||
imported.RailCollapsed = RailCollapsed;
|
||||
imported.LastEditedSequence = LastEditedSequence;
|
||||
imported.FirstRunCompleted = FirstRunCompleted;
|
||||
imported.WorkspaceFolder = WorkspaceFolder;
|
||||
imported.WorkspaceRecent = WorkspaceRecent;
|
||||
imported.WorkspaceOpened = WorkspaceOpened;
|
||||
return imported;
|
||||
}
|
||||
}
|
||||
|
||||
[JsonSourceGenerationOptions(WriteIndented = true, UseStringEnumConverter = true)]
|
||||
|
||||
Reference in new issue
Block a user