feat(workspace): move the workspace folder with its projects
Settings › Workspace › Change only pointed Edit at another folder and left every project behind. Moving a workspace to a bigger or faster disk now carries its projects along, without ever putting work at risk: - a plan first: projects, files, bytes, free space at the target, whether folders are renamed (one volume) or copied (another), projects with work not at their home as a warning; refused for the folder itself or one inside it, a target holding a workspace or a same-id folder, a target inside a library, too little room, or a workspace job still pending - the WorkspaceMove job checks the plan's fingerprint again, journals the move in <from>/.move.json, renames each entry on one volume, and across volumes copies each file to a .part, hashes both sides and only then renames it into place; the source goes only after every entry is verified and the desktop switched to the target - a failure before the switch is undone (renamed entries go back, copies are removed) so the source stays the workspace; a pause or a closed program goes on from the journal; a user cancel undoes it - while a move waits, runs or its journal is in the folder in use, opens, checkouts, copies, saves, syncs and another folder are refused, and a journal left at start is offered again with Resume - the setting names the new folder only once the move verified everything Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2e1c67f531
commit
c93a4b0779
8 files changed
+1670
-37
No files matched your search
@@ -329,13 +329,19 @@ public sealed partial class WorkspaceHost
|
||||
return (IReadOnlyList<WorkspaceEntry>)entries;
|
||||
}, cancellationToken);
|
||||
|
||||
/// <summary>The workspace projects of one sequence.</summary>
|
||||
public async Task<IReadOnlyList<WorkspaceEntry>> ProjectsOfAsync(Guid sequenceId, CancellationToken cancellationToken = default) =>
|
||||
[.. (await ListAsync(cancellationToken).ConfigureAwait(false)).Where(e => e.SequenceId == sequenceId)];
|
||||
/// <summary>The workspace projects of one sequence, as Edit opens one.</summary>
|
||||
/// <exception cref="WorkspaceException">The workspace folder is being moved (<c>Errors.Workspace.Moving</c>).</exception>
|
||||
public async Task<IReadOnlyList<WorkspaceEntry>> ProjectsOfAsync(Guid sequenceId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
EnsureNotMoving();
|
||||
return [.. (await ListAsync(cancellationToken).ConfigureAwait(false)).Where(e => e.SequenceId == sequenceId)];
|
||||
}
|
||||
|
||||
/// <summary>A workspace project by id (damaged or newer when this Chronos cannot read its working state); null when the workspace has none.</summary>
|
||||
/// <exception cref="WorkspaceException">The workspace folder is being moved (<c>Errors.Workspace.Moving</c>).</exception>
|
||||
public Task<WorkspaceEntry?> FindAsync(Guid projectId, CancellationToken cancellationToken = default) => Task.Run(async () =>
|
||||
{
|
||||
EnsureNotMoving();
|
||||
if (!Directory.Exists(Root) && await InsideALibraryAsync(cancellationToken).ConfigureAwait(false)) return null;
|
||||
return Store.Find(projectId) is { } project ? await EntryOrUnreadableAsync(project, cancellationToken).ConfigureAwait(false) : null;
|
||||
}, cancellationToken);
|
||||
@@ -363,11 +369,12 @@ public sealed partial class WorkspaceHost
|
||||
/// Edit's workspace becomes <paramref name="folder"/> (made, with its manifest, when it is new): Settings › Workspace ›
|
||||
/// Folder names it from now on (none when it is the default). The projects of the folder left stay there, untouched.
|
||||
/// </summary>
|
||||
/// <exception cref="WorkspaceException">The folder lies inside a library (<see cref="WorkspaceException.FolderRefused"/>).</exception>
|
||||
/// <exception cref="WorkspaceException">The folder lies inside a library (<see cref="WorkspaceException.FolderRefused"/>), or the workspace is being moved.</exception>
|
||||
/// <exception cref="IOException">The folder cannot be made or read.</exception>
|
||||
/// <exception cref="InvalidDataException">The folder holds another program's or a newer workspace manifest.</exception>
|
||||
public async Task UseFolderAsync(string folder, CancellationToken cancellationToken = default)
|
||||
{
|
||||
EnsureNotMoving();
|
||||
var plan = await PlanFolderAsync(folder, cancellationToken).ConfigureAwait(false);
|
||||
if (plan.IsSame) return;
|
||||
if (plan.InsideLibrary) throw new WorkspaceException(Loc.L("Errors.Workspace.InsideLibraryFolder", plan.Folder)) { FolderRefused = true };
|
||||
|
||||
Reference in new issue
Block a user