fix(workspace): close the phase 5c review findings

Originals are now judged by their bytes, never by the media index: a removal
or clean-up hashes every file under media/originals and deletes it only when
the home holds that SHA-256; every other file, named or not, goes to the
workspace trash. Trash entries are filled under a staging name that Empty
never lists. A ledger can only name files inside exports/.

Jobs follow the workspace: a copy, render or send resolves the folder that
holds its project now (a moved workspace, a retry after a move) and waits
while a move has not switched yet. A clean-up failure after the switch is a
warning that keeps the journal for a later resume; entries that changed
since they were copied are kept, and a same-volume rename refused across
volumes falls back to copy and verify.

Sends map a replayed version by content hash, or go with the project only,
and note an old server that drops provenance. The media index (format 2) and
project file (format 3) refuse older readers while they hold originals.
Metered connections also hold sync downloads and server copies. The editor
gains Send again, the Settings page can resume a stopped move, the disabled
tooltips say why, and unused strings are pruned.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-04 17:32:48 +01:00
1 parent 09fcff4eb2
commit 2654683a12
125 files changed
+1618 -401

No files matched your search

@@ -151,6 +151,51 @@ public abstract class WorkspaceOriginalsTests(TestContext context) : DatabaseTes
Assert.Equal(media.Frames[1].OriginalSha256, Sha(inTrash[0]));
}
[Test]
public async Task ACancelledCopyOfTheOriginalsRemovesWhatItWroteAndTrashesWhatTheHomeLacks()
{
var fx = await FixtureAsync();
var (store, sync) = fx.Workspace();
var project = await fx.CheckoutAsync(sync);
Assert.False(project.ReadMedia()!.HoldsOriginals);
var until = DateTime.UtcNow + TimeSpan.FromSeconds(TestTiming.Budget(30));
// Held so that the copy writes its originals and waits to record them; cancelled there.
var lease = await project.LockAsync(TimeSpan.FromSeconds(10), fx.Ct);
Job job;
try
{
job = await fx.StartCopyAsync(store, project.ProjectId, BundleMedia.Originals);
while (!(Directory.Exists(project.OriginalsDirectory)
&& Directory.GetFiles(project.OriginalsDirectory).Count(f => !f.EndsWith(".part", StringComparison.Ordinal)) == fx.Frames.Count))
{
if (DateTime.UtcNow > until) Assert.Fail("the copy's originals were not written");
await Task.Delay(20, fx.Ct);
}
// A file of bytes the home does not hold, and a download cut short.
File.WriteAllText(Path.Combine(project.OriginalsDirectory, "edited.jpg"), "not the home's photo");
File.WriteAllText(Path.Combine(project.OriginalsDirectory, Guid.NewGuid().ToString("N") + ".part"), "half");
await fx.CancelAsync(job.Id);
}
finally
{
lease.Dispose();
}
await fx.Archive.WaitForAsync(job.Id, JobState.Cancelled, (int)TestTiming.Budget(30));
while (Directory.Exists(project.OriginalsDirectory))
{
if (DateTime.UtcNow > until) Assert.Fail("the cancelled copy's originals stayed: " + string.Join(", ", Directory.GetFiles(project.OriginalsDirectory).Select(Path.GetFileName)));
await Task.Delay(20, fx.Ct);
}
// The media a copy finished before stay; the one file the home lacks is in the trash, never away.
var media = project.ReadMedia()!;
Assert.False(media.HoldsOriginals);
foreach (var frame in media.Frames) Assert.FileExists(project.MediaFile(frame.File!));
var inTrash = Directory.GetFiles(Path.Combine(store.Root, WorkspaceOriginals.TrashFolder), "*", SearchOption.AllDirectories);
Assert.SequenceEqual(["edited.jpg"], inTrash.Select(Path.GetFileName));
}
[Test]
public async Task ProxiesOnlyRefusesAPlanTheFilesChangedSince()
{