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:
1 parent
09fcff4eb2
commit
2654683a12
125 files changed
+1618
-401
No files matched your search
@@ -104,7 +104,17 @@ public sealed class WorkspaceSendServerTests(TestContext context)
|
||||
await using var db = await ChronosDatabase.OpenAsync(DatabaseOptions.Sqlite(Path.Combine(context.CreateTempDirectory("pc-db"), "chronos.db")), context.Cancellation);
|
||||
var archives = new ArchiveService(db, new ArchiveServiceOptions { Owner = "PC-A" });
|
||||
var metered = true;
|
||||
var options = WorkspaceJobOptions.For(archives) with { HoldTransfers = () => Volatile.Read(ref metered) };
|
||||
// Signalled once the send asks: from then on it waits, and nothing it holds went out.
|
||||
var asked = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var options = WorkspaceJobOptions.For(archives) with
|
||||
{
|
||||
HoldTransfers = () =>
|
||||
{
|
||||
var held = Volatile.Read(ref metered);
|
||||
if (held) asked.TrySetResult();
|
||||
return held;
|
||||
},
|
||||
};
|
||||
await using var engine = new JobEngine(db, WorkspaceJobs.CreateHandlers(db, archives, new Connector(client), options),
|
||||
new JobEngineOptions { Workers = 1, WorkerId = "PC-A", PollInterval = TimeSpan.FromMilliseconds(50), CheckpointInterval = TimeSpan.FromMilliseconds(50) });
|
||||
await engine.StartAsync(context.Cancellation);
|
||||
@@ -124,7 +134,7 @@ public sealed class WorkspaceSendServerTests(TestContext context)
|
||||
|
||||
// Held while the connection is metered: nothing goes out.
|
||||
var job = await engine.EnqueueAsync(WorkspaceJobs.Send(sid, Title, store.Root, main.Id, [entry.RenderId], serverKey), cancellationToken: context.Cancellation);
|
||||
await Task.Delay(TimeSpan.FromSeconds(1), context.Cancellation);
|
||||
await asked.Task.WaitAsync(Wait, context.Cancellation);
|
||||
Assert.Equal(JobState.Running, (await db.Jobs.GetAsync(job.Id, context.Cancellation))!.State);
|
||||
Assert.Null(await server.Database.Renders.GetAsync(entry.RenderId));
|
||||
Assert.True(project.ReadRenders().Find(entry.RenderId)!.IsUnsent);
|
||||
@@ -141,6 +151,43 @@ public sealed class WorkspaceSendServerTests(TestContext context)
|
||||
Assert.Empty(await db.Renders.ListBySequenceAsync(sid, context.Cancellation));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AnImageSequenceRenderedHereStaysInTheWorkspaceForAServerHome()
|
||||
{
|
||||
await using var server = await TestServer.StartAsync(context, services: ArchiveModule.Register);
|
||||
var (http, _, token) = await server.UserAsync("alberto", "editor");
|
||||
var sid = (await Uploads.UploadAsync(http, Photo(1), "IMG_0001.JPG", sessionKey: "roof")).SequenceId;
|
||||
using var client = new ChronosClient(server.HttpBase, new CertificatePinning([]), "PC-A") { Token = token };
|
||||
await using var db = await ChronosDatabase.OpenAsync(DatabaseOptions.Sqlite(Path.Combine(context.CreateTempDirectory("pc-db"), "chronos.db")), context.Cancellation);
|
||||
var archives = new ArchiveService(db, new ArchiveServiceOptions { Owner = "PC-A" });
|
||||
await using var engine = new JobEngine(db, WorkspaceJobs.CreateHandlers(db, archives, new Connector(client), WorkspaceJobOptions.For(archives)),
|
||||
new JobEngineOptions { Workers = 1, WorkerId = "PC-A", PollInterval = TimeSpan.FromMilliseconds(50), CheckpointInterval = TimeSpan.FromMilliseconds(50) });
|
||||
await engine.StartAsync(context.Cancellation);
|
||||
var store = new WorkspaceStore(Path.Combine(context.CreateTempDirectory("pc-ws"), "workspace"));
|
||||
var sync = new WorkspaceSync(store, "Chronos on PC-A") { LockWait = TimeSpan.FromSeconds(TestTiming.Budget(10)) };
|
||||
var home = new ServerProjectHome(client, sid, "Test server");
|
||||
var main = (await home.ListAsync(context.Cancellation)).Single();
|
||||
var project = await sync.CheckoutAsync(home, main.Id, cancellationToken: context.Cancellation);
|
||||
|
||||
// A TIFF sequence: a folder of frames, which a server's render (one file each) cannot take.
|
||||
var folder = Path.Combine(project.ExportsDirectory, "Roof frames");
|
||||
Directory.CreateDirectory(folder);
|
||||
for (var i = 1; i <= 3; i++) File.WriteAllBytes(Path.Combine(folder, $"{i:0000}.tif"), RandomNumberGenerator.GetBytes(4000));
|
||||
var entry = new WorkspaceRenderEntry(Guid.CreateVersion7(), Guid.CreateVersion7(), "Roof frames", new string('a', 64), 12_000, "TIFF sequence", "tiff",
|
||||
1920, 1080, 24, 0.125, main.Id, null, null, DateTimeOffset.UtcNow);
|
||||
project.WriteRenders(WorkspaceRenders.Empty.With(entry));
|
||||
|
||||
var job = await engine.EnqueueAsync(WorkspaceJobs.Send(sid, Title, store.Root, main.Id, [], SyncService.ServerKey(client.BaseAddress)),
|
||||
cancellationToken: context.Cancellation);
|
||||
var failed = await WaitAsync(db, job.Id, JobState.Failed);
|
||||
|
||||
Assert.Equal(Loc.L("Errors.Workspace.SendFailed", 1, 1), failed.Error);
|
||||
var kept = Assert.NotNull(project.ReadRenders().Find(entry.RenderId));
|
||||
Assert.Equal((WorkspaceRenderEntry.Failed, Loc.L("Errors.Workspace.SendSequence", "Roof frames")), (kept.State, kept.Error));
|
||||
Assert.Null(await server.Database.Renders.GetAsync(entry.RenderId));
|
||||
Assert.Equal(3, Directory.GetFiles(folder).Length);
|
||||
}
|
||||
|
||||
/// <summary>A render's file on this PC and the offer of it, naming no project.</summary>
|
||||
private (string Path, RenderUploadRequest Request) Output(int seed)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user