feat(workspace): copy originals into the workspace and choose the project Edit opens

Phase 5c P1. A workspace copy of kind "originals" now copies each frame's
original beside its proxy, so a later local render has full-quality input:
streamed into a .part file, hashed as written, checked against the home's
SHA-256, renamed and read back. Archive and server homes both work, a stopped
copy resumes (originals: checkpoint), and the space check counts the
originals. A frame whose original is gone, damaged or refused keeps its proxy
and the job says how many; the copy does not fail. Stale originals are
deleted only when the home holds the same SHA-256, otherwise moved to the
workspace's trash.

Proxies only... plans first (every original hashed against the home's
frames), asks for an explicit confirmation, rewrites the media to proxies
before it touches a file, refuses a plan that changed since, and trashes what
the home no longer holds instead of deleting it.

Edit: Open in workspace offers Originals (the settings' default, disabled
when the drive lacks room) with the originals' size for archive and server
homes; Settings > Workspace > Open project picks Last used, Main or asks
which; each open is recorded for the clean-up. The project menu gains Copy
originals... and Proxies only..., refused while changes are unsaved or jobs
of the sequence run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-04 15:43:42 +01:00
1 parent 2e1c67f531
commit 0c51d11080
14 files changed
+1397 -70

No files matched your search

@@ -197,14 +197,45 @@ public sealed class ServerWorkspaceTests(TestContext context)
// Another server's job for this project, or this server's for another sequence: refused, nothing downloaded.
var other = await a.EnqueueAsync(WorkspaceJobs.CopyFromServer(sid, Title, "https://elsewhere:8443", a.Store.Root, main.Id));
Assert.Equal(Loc.L("Errors.Workspace.OtherHome"), (await a.WaitAsync(other.Id, JobState.Failed)).Error);
var originals = await a.EnqueueAsync(WorkspaceJobs.CopyFromServer(sid, Title, a.Server, a.Store.Root, main.Id, BundleMedia.Originals));
Assert.Equal(Loc.L("Errors.Workspace.OriginalsLater"), (await a.WaitAsync(originals.Id, JobState.Failed)).Error);
a.Connected = false;
var signedOut = await a.EnqueueAsync(WorkspaceJobs.CopyFromServer(sid, Title, a.Server, a.Store.Root, main.Id));
Assert.Equal(Loc.L("Errors.Sync.NotConnected"), (await a.WaitAsync(signedOut.Id, JobState.Failed)).Error);
Assert.Null(a.Store.Find(main.Id)!.ReadMedia());
}
[Test]
public async Task TheOriginalsAreDownloadedCheckedAndKeptBesideTheProxies()
{
await using var server = await TestServer.StartAsync(context, services: ArchiveModule.Register);
var (_, _, token) = await server.UserAsync("alberto", "editor");
var sid = await SequenceAsync(server, token, 3);
await using var a = await WorkspaceClient.StartAsync(context, server, token, "PC-A");
var home = a.Home(sid);
var main = (await home.ListAsync(context.Cancellation)).Single();
var project = await a.Sync.CheckoutAsync(home, main.Id, BundleMedia.Originals, context.Cancellation);
var library = Listing(a.Archive.RootPath);
var job = await a.EnqueueAsync(WorkspaceJobs.CopyFromServer(sid, Title, a.Server, a.Store.Root, main.Id, BundleMedia.Originals));
job = await a.WaitAsync(job.Id, JobState.Done);
Assert.Contains(Loc.L("Archive.Log.WorkspaceOriginalsDownloaded", Title, 3, 0, 0), job.LogTail!);
var media = Assert.NotNull(project.ReadMedia());
Assert.True(media.HoldsOriginals);
Assert.Equal(BundleMedia.Originals, project.ReadBundle().Workspace!.Media.Kind);
var manifest = await a.Client.GetManifestAsync(sid, context.Cancellation);
foreach (var (frame, entry) in manifest.Frames.OrderBy(f => f.Index).Zip(media.Frames))
{
Assert.Equal(frame.Sha256.ToLowerInvariant(), entry.OriginalSha256);
Assert.Equal(entry.OriginalSha256, Sha(project.MediaFile(Assert.NotNull(entry.Original))));
Assert.NotNull(entry.File);
}
Assert.False(Directory.Exists(Path.Combine(project.OriginalsDirectory, ".staging")));
Assert.SequenceEqual(library, Listing(a.Archive.RootPath), "this PC's library is as it was");
// Again: every original held is kept, hashed again.
job = await a.WaitAsync((await a.EnqueueAsync(WorkspaceJobs.CopyFromServer(sid, Title, a.Server, a.Store.Root, main.Id, BundleMedia.Originals))).Id, JobState.Done);
Assert.Contains(Loc.L("Archive.Log.WorkspaceOriginalsDownloaded", Title, 0, 3, 0), job.LogTail!);
}
[Test]
public async Task AProjectDeletedOnTheServerIsGoneAndItsCopyStays()
{