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
@@ -66,6 +66,31 @@ public static class WorkspaceFolderChange
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Settings › Workspace › Move… (phase 5c): the shell's flow over <see cref="MoveAsync(WorkspaceHost, IAppDialogs, Func{Task{bool}}, Action{string})"/>,
|
||||
/// with its folder picker, confirmation, editor and toasts. True when the move was queued.
|
||||
/// </summary>
|
||||
public static Task<bool> MoveAsync(ShellViewModel shell)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(shell);
|
||||
throw new NotImplementedException("Moving the workspace folder comes with phase 5c (P6).");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Picks the folder the workspace moves to through <paramref name="dialogs"/>, shows its plan
|
||||
/// (<see cref="WorkspaceHost.PlanMoveAsync"/>) and asks for the user's word, lets <paramref name="closeProject"/> close a
|
||||
/// workspace project open in the editor (false keeps everything as it is), then queues the move
|
||||
/// (<see cref="WorkspaceHost.QueueMoveAsync"/>). <paramref name="failed"/> hears why it was refused. True when it was queued.
|
||||
/// </summary>
|
||||
public static Task<bool> MoveAsync(WorkspaceHost host, IAppDialogs dialogs, Func<Task<bool>> closeProject, Action<string> failed)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(host);
|
||||
ArgumentNullException.ThrowIfNull(dialogs);
|
||||
ArgumentNullException.ThrowIfNull(closeProject);
|
||||
ArgumentNullException.ThrowIfNull(failed);
|
||||
throw new NotImplementedException("Moving the workspace folder comes with phase 5c (P6).");
|
||||
}
|
||||
|
||||
/// <summary>The plan as a confirmation: where Edit's projects come from now, and what stays where it is.</summary>
|
||||
public static ConfirmRequest Request(WorkspaceFolderPlan plan)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
using System.IO;
|
||||
using Chronos.Core.Project;
|
||||
using Chronos.Data.Workspaces;
|
||||
|
||||
namespace Chronos.App.Workspace;
|
||||
|
||||
/// <summary>
|
||||
/// What the workspace takes of its drive (Settings › Workspace, phase 5c): the projects' media (proxies and originals, which
|
||||
/// the clean-up and the size limit may remove), the whole folder, and its trash (<see cref="WorkspaceHost.TrashFolder"/>).
|
||||
/// </summary>
|
||||
/// <param name="MediaBytes">The bytes of every project's <c>media/</c> folder.</param>
|
||||
/// <param name="TotalBytes">The bytes of the whole workspace folder, its trash included.</param>
|
||||
/// <param name="TrashBytes">The bytes of the workspace's trash.</param>
|
||||
/// <param name="TrashItems">The entries of the workspace's trash (one per copy removed or originals set aside).</param>
|
||||
public sealed record WorkspaceUsage(long MediaBytes, long TotalBytes, long TrashBytes, int TrashItems)
|
||||
{
|
||||
/// <summary>A workspace that holds nothing.</summary>
|
||||
public static WorkspaceUsage None { get; } = new(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/// <summary>One entry of the workspace's trash as Empty… lists it: its folder name, size, files and when it was put there.</summary>
|
||||
public sealed record WorkspaceTrashItem(string Name, long Bytes, int Files, DateTimeOffset Trashed);
|
||||
|
||||
/// <summary>
|
||||
/// The plan of Settings › Workspace › Trash › Empty… (phase 5c): every entry of the workspace's trash and their bytes, and a
|
||||
/// fingerprint over their names, sizes and times. Emptying erases exactly these entries, and only while the fingerprint
|
||||
/// still matches (the user types the number of entries to confirm); schedules and the size limit never empty the trash.
|
||||
/// </summary>
|
||||
public sealed record WorkspaceTrashPlan(string Folder, IReadOnlyList<WorkspaceTrashItem> Items, long Bytes, string Fingerprint)
|
||||
{
|
||||
/// <summary>Nothing to erase: Empty… is disabled.</summary>
|
||||
public bool IsEmpty => Items.Count == 0;
|
||||
}
|
||||
|
||||
/// <summary>What emptying the workspace's trash erased.</summary>
|
||||
public sealed record WorkspaceTrashResult(int Items, long Bytes);
|
||||
|
||||
/// <summary>
|
||||
/// The workspace's clean-up side (phase 5c, P4): its usage, the plan and emptying of its trash, and what a local copy's removal
|
||||
/// keeps of renders not sent and originals the home lost. Stubs until the clean-up lands: usage and the trash read as empty,
|
||||
/// and a removal finds nothing more to keep.
|
||||
/// </summary>
|
||||
public sealed partial class WorkspaceHost
|
||||
{
|
||||
/// <summary>What the workspace takes of its drive (<see cref="WorkspaceUsage"/>), measured off the UI thread.</summary>
|
||||
public Task<WorkspaceUsage> UsageAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return Task.FromResult(WorkspaceUsage.None);
|
||||
}
|
||||
|
||||
/// <summary>The plan of emptying the workspace's trash (<see cref="WorkspaceTrashPlan"/>); nothing is erased.</summary>
|
||||
public Task<WorkspaceTrashPlan> PlanTrashAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return Task.FromResult(new WorkspaceTrashPlan(Path.Combine(Root, TrashFolder), [], 0, string.Empty));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Erases the entries of <paramref name="plan"/> from the workspace's trash for good, after the user typed their number;
|
||||
/// refused when the trash changed since the plan (<c>Errors.Workspace.TrashChanged</c>).
|
||||
/// </summary>
|
||||
/// <exception cref="WorkspaceException">The trash changed since the plan; nothing was erased.</exception>
|
||||
public Task<WorkspaceTrashResult> EmptyTrashAsync(WorkspaceTrashPlan plan, CancellationToken cancellationToken = default)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(plan);
|
||||
throw new NotImplementedException("Emptying the workspace's trash comes with phase 5c (P4).");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// What a local copy's removal plan counts besides its versions (<see cref="WorkspaceRemovalPlan.UnsentRenders"/>,
|
||||
/// <see cref="WorkspaceRemovalPlan.LastOriginals"/>): renders of its ledger not sent, and originals the home no longer holds.
|
||||
/// </summary>
|
||||
private Task<(int UnsentRenders, int LastOriginals)> RemovalMediaAsync(WorkspaceProject project, CancellationToken cancellationToken)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(project);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return Task.FromResult((0, 0));
|
||||
}
|
||||
|
||||
/// <summary>A removal without Discard is refused while the project's ledger holds renders not sent (Send first sends them).</summary>
|
||||
/// <exception cref="WorkspaceException">Renders wait to be sent.</exception>
|
||||
private Task EnsureRendersSentAsync(WorkspaceProject project, BundleWorkspace workspace, CancellationToken cancellationToken)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(project);
|
||||
ArgumentNullException.ThrowIfNull(workspace);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Before a removed copy's media are deleted, under the project's lease: the originals the home no longer holds with the
|
||||
/// same SHA-256 moved into <paramref name="aside"/> (the copy's trash entry), never deleted.
|
||||
/// </summary>
|
||||
private Task KeepLastOriginalsAsync(WorkspaceProject project, string aside, CancellationToken cancellationToken)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(project);
|
||||
ArgumentException.ThrowIfNullOrEmpty(aside);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Data.Workspaces;
|
||||
|
||||
namespace Chronos.App.Workspace;
|
||||
|
||||
/// <summary>
|
||||
/// The workspace's media (phase 5c, P1): what a copy writes (proxies, and the originals besides), copying the originals of a
|
||||
/// project, and going back to proxies only.
|
||||
/// </summary>
|
||||
public sealed partial class WorkspaceHost
|
||||
{
|
||||
/// <summary>The bytes the first copy of a sequence's media writes into the workspace, and the free bytes of the workspace's drive.</summary>
|
||||
/// <exception cref="WorkspaceException">The index or the archive engine is not open.</exception>
|
||||
public Task<WorkspaceCopyFacts> CopyFactsAsync(Guid sequenceId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var db = _db() ?? throw new WorkspaceException(Loc.L("Editor.Error.NoEngine"));
|
||||
var archives = _archives() ?? throw new WorkspaceException(Loc.L("Editor.Error.NoEngine"));
|
||||
var root = Root;
|
||||
return Task.Run(async () =>
|
||||
{
|
||||
var (bytes, free) = await WorkspaceJobs.CopyFactsAsync(db, archives, sequenceId, root, cancellationToken).ConfigureAwait(false);
|
||||
return new WorkspaceCopyFacts(bytes, free);
|
||||
}, cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -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"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Chronos.App.Workspace;
|
||||
|
||||
/// <summary>
|
||||
/// The workspace's local renders (phase 5c, P2): rendering a project from the originals it holds on this PC, and sending its
|
||||
/// renders home.
|
||||
/// </summary>
|
||||
public sealed partial class WorkspaceHost
|
||||
{
|
||||
}
|
||||
@@ -70,8 +70,17 @@ public sealed record WorkspaceFolderPlan(string Current, string Folder, int Proj
|
||||
}
|
||||
|
||||
/// <summary>What "Open in workspace" shows of the copy it queues: its bytes (as the copy reckons them) and the free bytes of the workspace's drive.</summary>
|
||||
public sealed record WorkspaceCopyFacts(long Bytes, long? Free)
|
||||
/// <param name="Bytes">What the copy of the proxies writes.</param>
|
||||
/// <param name="OriginalsBytes">What the copy of the originals writes besides (phase 5c); null when not known.</param>
|
||||
public sealed record WorkspaceCopyFacts(long Bytes, long? Free, long? OriginalsBytes = null)
|
||||
{
|
||||
/// <summary>
|
||||
/// The drive lacks room for the copy of <paramref name="media"/> (<see cref="BundleMedia.Originals"/>: the proxies and the
|
||||
/// originals) and the reserve the copy keeps free.
|
||||
/// </summary>
|
||||
public bool TooLittleSpaceFor(string media) =>
|
||||
Free is { } free && free < Bytes + (media == BundleMedia.Originals ? OriginalsBytes ?? 0 : 0) + WorkspaceJobs.CopySpaceReserve;
|
||||
|
||||
/// <summary>The drive lacks the copy and the reserve the copy keeps: it would stop saying so.</summary>
|
||||
public bool TooLittleSpace => Free is { } free && free < Bytes + WorkspaceJobs.CopySpaceReserve;
|
||||
}
|
||||
@@ -113,8 +122,20 @@ public sealed record WorkspaceRemovalPlan(Guid ProjectId, string Name, int Files
|
||||
/// </summary>
|
||||
public string? KnownName { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Local renders not at the home yet (phase 5c, the project's ledger): Send first sends them, Discard keeps them in the
|
||||
/// workspace's trash with the rest of the work not sent.
|
||||
/// </summary>
|
||||
public int UnsentRenders { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Originals the workspace holds that the home no longer holds with the same SHA-256 (phase 5c): they go to the
|
||||
/// workspace's trash, never deleted, when the copy is removed.
|
||||
/// </summary>
|
||||
public int LastOriginals { get; init; }
|
||||
|
||||
/// <summary>Everything the copy holds is at the home: it can go without discarding anything.</summary>
|
||||
public bool IsSafe => Unsent == 0 && !Modified && !Conflict && !Damaged;
|
||||
public bool IsSafe => Unsent == 0 && UnsentRenders == 0 && !Modified && !Conflict && !Damaged;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -129,7 +150,7 @@ public sealed record WorkspaceRemovalPlan(Guid ProjectId, string Name, int Files
|
||||
/// Workspace › Kept versions only after the home returned each, a page of its history at a time. A capture (sample data, no
|
||||
/// engine) has no workspace: Edit opens the library there.
|
||||
/// </summary>
|
||||
public sealed class WorkspaceHost
|
||||
public sealed partial class WorkspaceHost
|
||||
{
|
||||
/// <summary>Where discarded work of removed local copies is kept (the store lists only folders named by a project id).</summary>
|
||||
public const string TrashFolder = ".trash";
|
||||
@@ -358,20 +379,6 @@ public sealed class WorkspaceHost
|
||||
Log.Info("workspace", $"The workspace folder is now {plan.Folder} ({plan.ProjectsLeft} project(s) stay in {plan.Current})");
|
||||
}
|
||||
|
||||
/// <summary>The bytes the first copy of a sequence's media writes into the workspace, and the free bytes of the workspace's drive.</summary>
|
||||
/// <exception cref="WorkspaceException">The index or the archive engine is not open.</exception>
|
||||
public Task<WorkspaceCopyFacts> CopyFactsAsync(Guid sequenceId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var db = _db() ?? throw new WorkspaceException(Loc.L("Editor.Error.NoEngine"));
|
||||
var archives = _archives() ?? throw new WorkspaceException(Loc.L("Editor.Error.NoEngine"));
|
||||
var root = Root;
|
||||
return Task.Run(async () =>
|
||||
{
|
||||
var (bytes, free) = await WorkspaceJobs.CopyFactsAsync(db, archives, sequenceId, root, cancellationToken).ConfigureAwait(false);
|
||||
return new WorkspaceCopyFacts(bytes, free);
|
||||
}, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>The project of <paramref name="sequenceId"/> opened last here, else the one saved last; null when the workspace has none.</summary>
|
||||
public async Task<WorkspaceEntry?> LastUsedAsync(Guid sequenceId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
@@ -388,6 +395,16 @@ public sealed class WorkspaceHost
|
||||
_savePreferences();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Records that Edit opened <paramref name="projectId"/> at <paramref name="at"/> (now when null): the clean-up's Clean
|
||||
/// after goes by it (phase 5c, <see cref="AppSettings.WorkspaceOpened"/>). Call it on the UI thread, which writes the settings.
|
||||
/// </summary>
|
||||
public void RecordOpened(Guid projectId, DateTimeOffset? at = null)
|
||||
{
|
||||
_settings.WorkspaceOpened[projectId] = at ?? DateTimeOffset.UtcNow;
|
||||
_savePreferences();
|
||||
}
|
||||
|
||||
/// <summary>The home's live projects of a sequence, Main first (made from the sequence's settings when it has none yet).</summary>
|
||||
public Task<IReadOnlyList<SequenceProject>> HomeProjectsAsync(Guid sequenceId, CancellationToken cancellationToken = default) =>
|
||||
HomeProjectsAsync(ArchiveHome(sequenceId), cancellationToken);
|
||||
@@ -426,6 +443,7 @@ public sealed class WorkspaceHost
|
||||
var sequenceId = home.SequenceId;
|
||||
var checkout = await Task.Run(async () =>
|
||||
{
|
||||
EnsureNotMoving();
|
||||
// Refused before anything is written: the copy job would refuse such a folder after the checkout filled it.
|
||||
if (await InsideALibraryAsync(cancellationToken).ConfigureAwait(false))
|
||||
throw new WorkspaceException(Loc.L("Errors.Workspace.InsideLibraryEdit", Root)) { FolderRefused = true };
|
||||
@@ -461,6 +479,7 @@ public sealed class WorkspaceHost
|
||||
/// </summary>
|
||||
public Task<Job> QueueCopyAsync(Guid projectId, CancellationToken cancellationToken = default) => Task.Run(async () =>
|
||||
{
|
||||
EnsureNotMoving();
|
||||
var bundle = Existing(projectId).ReadBundle();
|
||||
return await QueueCopyCoreAsync(bundle.Workspace!.Home, projectId, bundle.Workspace.Media.Kind, bundle.Sequence.Title ?? string.Empty, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
@@ -516,6 +535,7 @@ public sealed class WorkspaceHost
|
||||
{
|
||||
var version = await Task.Run(async () =>
|
||||
{
|
||||
EnsureNotMoving();
|
||||
EnsureWritable(await Sync.StatusAsync(projectId, null, cancellationToken).ConfigureAwait(false));
|
||||
return await Sync.CommitAsync(projectId, note, null, cancellationToken).ConfigureAwait(false);
|
||||
}, cancellationToken).ConfigureAwait(false);
|
||||
@@ -538,6 +558,7 @@ public sealed class WorkspaceHost
|
||||
/// <summary>The working state as a new local version without a note and without sending it; null when nothing changed.</summary>
|
||||
public Task<ProjectVersion?> CommitAsync(Guid projectId, CancellationToken cancellationToken = default) => Task.Run(async () =>
|
||||
{
|
||||
EnsureNotMoving();
|
||||
EnsureWritable(await Sync.StatusAsync(projectId, null, cancellationToken).ConfigureAwait(false));
|
||||
return await Sync.CommitAsync(projectId, null, null, cancellationToken).ConfigureAwait(false);
|
||||
}, cancellationToken);
|
||||
@@ -551,6 +572,7 @@ public sealed class WorkspaceHost
|
||||
/// <exception cref="WorkspaceSyncException">The home refused a version for good.</exception>
|
||||
public Task<WorkspaceSyncResult> SyncAsync(Guid projectId, CancellationToken cancellationToken = default) => Task.Run(async () =>
|
||||
{
|
||||
EnsureNotMoving();
|
||||
var home = HomeOfProject(projectId);
|
||||
var pulled = await Sync.PullAsync(projectId, home, cancellationToken).ConfigureAwait(false);
|
||||
// Deleted at the library: nothing to send, nothing to prune; the copy stays as it is.
|
||||
@@ -570,6 +592,7 @@ public sealed class WorkspaceHost
|
||||
public Task<WorkspaceSyncResult> ResolveAsync(Guid projectId, ConflictChoice choice, IReadOnlySet<string>? takeServer = null,
|
||||
WorkspaceConflict? shown = null, CancellationToken cancellationToken = default) => Task.Run(async () =>
|
||||
{
|
||||
EnsureNotMoving();
|
||||
var home = HomeOfProject(projectId);
|
||||
WorkspaceSyncResult resolved;
|
||||
if (choice == ConflictChoice.SaveBoth)
|
||||
@@ -619,6 +642,7 @@ public sealed class WorkspaceHost
|
||||
/// </summary>
|
||||
public Task<ProjectSettings> RestoreAsync(Guid projectId, Guid versionId, CancellationToken cancellationToken = default) => Task.Run(async () =>
|
||||
{
|
||||
EnsureNotMoving();
|
||||
var status = await Sync.StatusAsync(projectId, null, cancellationToken).ConfigureAwait(false);
|
||||
if (status.ReadOnly) throw new WorkspaceException(Loc.L("Errors.Workspace.ReadOnly"));
|
||||
if (status.MediaRemoved) throw new WorkspaceException(Loc.L("Errors.Workspace.MediaMissing"));
|
||||
@@ -766,8 +790,9 @@ public sealed class WorkspaceHost
|
||||
// A conflict recorded counts as work not at the home, also once the library no longer has the project (Gone asks none);
|
||||
// one a settling replay took past its commit point is over, as the status reads it.
|
||||
var conflict = status.Conflict is not null || project.OpenConflict() is not null;
|
||||
var (unsentRenders, lastOriginals) = await RemovalMediaAsync(project, cancellationToken).ConfigureAwait(false);
|
||||
return new WorkspaceRemovalPlan(projectId, name, files, bytes, status.Ahead + status.Damaged, status.Modified, conflict, status.Offline,
|
||||
status.State == WorkspaceState.Gone);
|
||||
status.State == WorkspaceState.Gone) { UnsentRenders = unsentRenders, LastOriginals = lastOriginals };
|
||||
}, cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
@@ -802,6 +827,7 @@ public sealed class WorkspaceHost
|
||||
// A version saved here that cannot be read may be one the home never had: only discarding keeps it aside.
|
||||
if (status.Ahead > 0 || status.Damaged > 0 || (status.Modified && !status.ReadOnly) || status.Conflict is not null)
|
||||
throw new WorkspaceException(Unsent(workspace.Home));
|
||||
await EnsureRendersSentAsync(project, workspace, cancellationToken).ConfigureAwait(false);
|
||||
await VerifyHomeAsync(projectId, workspace, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
await RemoveFolderAsync(project, cancellationToken).ConfigureAwait(false);
|
||||
@@ -950,6 +976,8 @@ public sealed class WorkspaceHost
|
||||
}
|
||||
throw;
|
||||
}
|
||||
// Originals the home no longer holds go aside with the rest; only what the home can make again is deleted.
|
||||
await KeepLastOriginalsAsync(project, aside, cancellationToken).ConfigureAwait(false);
|
||||
if (Directory.Exists(project.MediaDirectory)) Directory.Delete(project.MediaDirectory, recursive: true);
|
||||
|
||||
void Move(string from, string to)
|
||||
@@ -1007,9 +1035,13 @@ public sealed class WorkspaceHost
|
||||
|
||||
private void Forget(Guid sequenceId, Guid projectId)
|
||||
{
|
||||
if (!_settings.WorkspaceRecent.TryGetValue(sequenceId, out var known) || known != projectId) return;
|
||||
_settings.WorkspaceRecent.Remove(sequenceId);
|
||||
_savePreferences();
|
||||
var changed = _settings.WorkspaceOpened.Remove(projectId);
|
||||
if (_settings.WorkspaceRecent.TryGetValue(sequenceId, out var known) && known == projectId)
|
||||
{
|
||||
_settings.WorkspaceRecent.Remove(sequenceId);
|
||||
changed = true;
|
||||
}
|
||||
if (changed) _savePreferences();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in new issue
Block a user