feat(workspace): lay the phase 5c foundation
Phase 5c (owner review 2, R8) is built by six packages in parallel. This commit settles everything they share, so each one touches its own files: - job kinds WorkspaceRender (21), WorkspaceSend (22) and WorkspaceMove (23) with their wire names, default priorities, notices and parameter records; their handlers are registered as skeletons that throw until their package lands - WorkspaceJobOptions and a new CreateHandlers overload; the earlier ones stay and default the options - originals in the media index (an index of phase 5b reads as proxies only), their file names, and the exports/renders.json ledger of local renders, written atomically - the optional project and version of an uploaded render - the workspace settings (size limit, default media, version on render, clean-up age, project to open) and when each project was opened, which Reset and Import keep and Export leaves out - WorkspaceHost split into partial files, with stubs for usage, trash and the folder move, removal hooks for unsent renders and last originals, and a guard that holds work while the workspace moves - every new string of the phase in English and Italian, with tooltips Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
102f28b5df
commit
2e1c67f531
43 files changed
+1725
-128
No files matched your search
@@ -0,0 +1,76 @@
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Core.Model;
|
||||
|
||||
namespace Chronos.App.Workspace;
|
||||
|
||||
/// <summary>A project of the workspace as the plan of a move lists it: its size, and work not at its home yet (a warning, never a refusal).</summary>
|
||||
/// <param name="Unsent">Versions or renders wait to be sent to its home.</param>
|
||||
/// <param name="Modified">Changes not saved as a version.</param>
|
||||
public sealed record WorkspaceMoveProject(Guid ProjectId, string Name, int Files, long Bytes, bool Unsent, bool Modified);
|
||||
|
||||
/// <summary>
|
||||
/// The plan of Settings › Workspace › Move… (phase 5c): the workspace folder <see cref="From"/> moved with its projects to
|
||||
/// <see cref="To"/>: the projects and their bytes, the free bytes at the target, whether both lie on one volume (folders
|
||||
/// renamed) or not (files copied and hash-verified), why it is refused (null when it can go), and a fingerprint of what
|
||||
/// the plan read, which the move job checks again.
|
||||
/// </summary>
|
||||
/// <param name="Free">The free bytes of the target's drive; null when they cannot be measured.</param>
|
||||
/// <param name="Refusal">
|
||||
/// Why the move cannot go, one localized sentence: the target is the folder itself or inside it
|
||||
/// (<c>Errors.Workspace.MoveSameFolder</c>), already holds a workspace or a project of the same id
|
||||
/// (<c>Errors.Workspace.MoveTargetNotEmpty</c>), lacks the room (<c>Errors.Workspace.DiskFull</c>), or a workspace job is
|
||||
/// pending or running (<c>Errors.Workspace.JobsRunning</c>); null when it can go.
|
||||
/// </param>
|
||||
public sealed record WorkspaceMovePlan(string From, string To, IReadOnlyList<WorkspaceMoveProject> Projects, int Files, long Bytes, long? Free, bool SameVolume,
|
||||
string? Refusal, string Fingerprint)
|
||||
{
|
||||
/// <summary>Nothing refuses the move.</summary>
|
||||
public bool CanMove => Refusal is null;
|
||||
|
||||
/// <summary>Projects with work not at their home: the move keeps it, the plan says so.</summary>
|
||||
public int Warnings => Projects.Count(p => p.Unsent || p.Modified);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moving the workspace folder with its projects (phase 5c, P6): the plan, the <see cref="JobKind.WorkspaceMove"/> that
|
||||
/// carries it out, and the workspace that follows the folder once every file is verified there. While a move is queued or
|
||||
/// running the workspace is refused for syncs, saves and opens (<see cref="EnsureNotMoving"/>). Stubs until the move lands.
|
||||
/// </summary>
|
||||
public sealed partial class WorkspaceHost
|
||||
{
|
||||
/// <summary>A move of the workspace folder is queued or running: syncs, saves and opens wait for it.</summary>
|
||||
public bool IsMoving => false;
|
||||
|
||||
/// <summary>The plan of moving the workspace folder to <paramref name="to"/> (<see cref="WorkspaceMovePlan"/>); nothing is written.</summary>
|
||||
public Task<WorkspaceMovePlan> PlanMoveAsync(string to, CancellationToken cancellationToken = default)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(to);
|
||||
throw new NotImplementedException("Moving the workspace folder comes with phase 5c (P6).");
|
||||
}
|
||||
|
||||
/// <summary>Queues the <see cref="JobKind.WorkspaceMove"/> of a plan the user confirmed.</summary>
|
||||
/// <exception cref="WorkspaceException">The plan refuses the move.</exception>
|
||||
public Task<Job> QueueMoveAsync(WorkspaceMovePlan plan, CancellationToken cancellationToken = default)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(plan);
|
||||
throw new NotImplementedException("Moving the workspace folder comes with phase 5c (P6).");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Told by the move job once every file of the workspace is verified at <paramref name="to"/>
|
||||
/// (<c>WorkspaceJobOptions.Moved</c>): Settings › Workspace names the new folder and the workspace opens there.
|
||||
/// </summary>
|
||||
public Task MovedAsync(string from, string to)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(from);
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(to);
|
||||
throw new NotImplementedException("Moving the workspace folder comes with phase 5c (P6).");
|
||||
}
|
||||
|
||||
/// <summary>Refuses an operation that writes into the workspace while its folder is being moved.</summary>
|
||||
/// <exception cref="WorkspaceException">A move is queued or running (<c>Errors.Workspace.Moving</c>).</exception>
|
||||
private void EnsureNotMoving()
|
||||
{
|
||||
if (IsMoving) throw new WorkspaceException(Loc.L("Errors.Workspace.Moving"));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user