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
@@ -184,6 +184,36 @@ public sealed class ServerWorkspaceTests(TestContext context)
|
||||
static int Downloaded(WorkspaceMedia media, Range frames) => media.Frames.Take(frames).Count(f => f.FileKind == "proxy");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ACopyFromTheServerWaitsWhileTheConnectionIsMetered()
|
||||
{
|
||||
await using var server = await TestServer.StartAsync(context, services: ArchiveModule.Register);
|
||||
var (_, _, token) = await server.UserAsync("alberto", "editor");
|
||||
var sid = await SequenceAsync(server, token, 2);
|
||||
var metered = true;
|
||||
var asked = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
await using var a = await WorkspaceClient.StartAsync(context, server, token, "PC-A", hold: () =>
|
||||
{
|
||||
var held = Volatile.Read(ref metered);
|
||||
if (held) asked.TrySetResult();
|
||||
return held;
|
||||
});
|
||||
var home = a.Home(sid);
|
||||
var main = (await home.ListAsync(context.Cancellation)).Single();
|
||||
var project = await a.Sync.CheckoutAsync(home, main.Id, cancellationToken: context.Cancellation);
|
||||
|
||||
// Held before anything is downloaded.
|
||||
var job = await a.EnqueueAsync(WorkspaceJobs.CopyFromServer(sid, Title, a.Server, a.Store.Root, main.Id));
|
||||
await asked.Task.WaitAsync(Wait, context.Cancellation);
|
||||
Assert.Equal(JobState.Running, (await a.Db.Jobs.GetAsync(job.Id, context.Cancellation))!.State);
|
||||
Assert.False(Directory.Exists(project.ProxiesDirectory) && Directory.EnumerateFiles(project.ProxiesDirectory).Any(), "nothing downloaded while metered");
|
||||
|
||||
Volatile.Write(ref metered, false);
|
||||
var done = await a.WaitAsync(job.Id, JobState.Done);
|
||||
Assert.Contains(Loc.L("Archive.Log.WorkspaceCopyHeld"), done.LogTail!);
|
||||
Assert.Equal(2, Assert.NotNull(project.ReadMedia()).Frames.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ACopyIsRefusedForAnotherHomeOrWithoutTheServer()
|
||||
{
|
||||
@@ -529,7 +559,8 @@ public sealed class ServerWorkspaceTests(TestContext context)
|
||||
/// <summary>Whether the copy job finds this PC signed in to the server.</summary>
|
||||
public bool Connected { get; set; } = true;
|
||||
|
||||
public static async Task<WorkspaceClient> StartAsync(TestContext context, TestServer server, string token, string name, HttpMessageHandler? handler = null)
|
||||
public static async Task<WorkspaceClient> StartAsync(TestContext context, TestServer server, string token, string name, HttpMessageHandler? handler = null,
|
||||
Func<bool>? hold = null)
|
||||
{
|
||||
var db = await ChronosDatabase.OpenAsync(DatabaseOptions.Sqlite(Path.Combine(context.CreateTempDirectory(name + "-db"), "chronos.db")), context.Cancellation);
|
||||
var archives = new ArchiveService(db, new ArchiveServiceOptions { Owner = name });
|
||||
@@ -537,7 +568,8 @@ public sealed class ServerWorkspaceTests(TestContext context)
|
||||
var archive = await archives.CreateAsync(context.CreateTempDirectory(name + "-archive"), "Local", cancellationToken: context.Cancellation);
|
||||
var client = new ChronosClient(server.HttpBase, new CertificatePinning([]), name, handler) { Token = token };
|
||||
WorkspaceClient? created = null;
|
||||
var engine = new JobEngine(db, WorkspaceJobs.CreateHandlers(db, archives, new Connector(client, () => created?.Connected ?? true)),
|
||||
var options = hold is null ? WorkspaceJobOptions.For(archives) : WorkspaceJobOptions.For(archives) with { HoldTransfers = hold };
|
||||
var engine = new JobEngine(db, WorkspaceJobs.CreateHandlers(db, archives, new Connector(client, () => created?.Connected ?? true), options),
|
||||
new JobEngineOptions { Workers = 1, WorkerId = name, PollInterval = TimeSpan.FromMilliseconds(50), CheckpointInterval = TimeSpan.FromMilliseconds(50) });
|
||||
await engine.StartAsync(context.Cancellation);
|
||||
var store = new WorkspaceStore(Path.Combine(context.CreateTempDirectory(name + "-ws"), "workspace"));
|
||||
|
||||
Reference in new issue
Block a user