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
@@ -12,6 +12,7 @@ using Chronos.Data.Processing;
|
||||
using Chronos.Data.Workspaces;
|
||||
using Chronos.Protocol.Client;
|
||||
using Chronos.Testing;
|
||||
using Chronos.Ui.Mvvm;
|
||||
|
||||
namespace Chronos.App.Tests.Workspace;
|
||||
|
||||
@@ -84,6 +85,81 @@ public sealed class WorkspaceLocalRenderTests(TestContext context)
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ProxiesOnlyAsksWithItsPlanAndRemovesNothingUntilConfirmed()
|
||||
{
|
||||
await using var bed = await WorkspaceTestBed.CreateAsync(context, frames: 4);
|
||||
var host = bed.Host(new AppSettings { WorkspaceAutoSync = false });
|
||||
var checkout = await host.CheckoutAsync(bed.SequenceId, null, null, BundleMedia.Originals, cancellationToken: bed.Ct);
|
||||
await bed.WaitForJobAsync(checkout.Copy.Id);
|
||||
var projectId = checkout.Project.Id;
|
||||
var folder = host.Store.Find(projectId)!;
|
||||
var (source, session) = await bed.OpenAsync(host, projectId);
|
||||
var ui = new RecordingUi { ConfirmAnswer = false };
|
||||
await using (session)
|
||||
using (var menu = new ProjectMenuViewModel(host, source, session, ui))
|
||||
{
|
||||
await menu.RefreshAsync();
|
||||
Assert.True(menu.HoldsOriginals);
|
||||
Assert.False(menu.CopyOriginalsCommand.CanExecute(null));
|
||||
Assert.Equal(Loc.L("Tooltips.Editor.Project.HasOriginals"), menu.CopyOriginalsToolTip, "says why it is disabled");
|
||||
Assert.Equal(Loc.L("Tooltips.Editor.Project.ProxiesOnly"), menu.ProxiesOnlyToolTip);
|
||||
var originals = Directory.GetFiles(folder.OriginalsDirectory).Length;
|
||||
Assert.Equal(4, originals);
|
||||
var plan = await host.PlanProxiesOnlyAsync(projectId, bed.Ct);
|
||||
Assert.Equal(4, plan.Originals + plan.ToTrash);
|
||||
|
||||
// Asked first, with the plan: kept on Keep.
|
||||
var command = (AsyncRelayCommand)menu.ProxiesOnlyCommand;
|
||||
command.Execute(null);
|
||||
await WorkspaceTestBed.UntilAsync(() => ui.Confirmations.Count == 1 && !command.IsRunning, "the question");
|
||||
var asked = ui.Confirmations[0];
|
||||
Assert.Equal(Loc.L("Editor.ProxiesOnly.Title", menu.Name), asked.Heading);
|
||||
Assert.True(asked.IsDestructive);
|
||||
Assert.Contains(Loc.L("Editor.ProxiesOnly.Originals", Formatting.Count(plan.Originals)), asked.Detail!);
|
||||
if (plan.ToTrash > 0) Assert.Contains(Loc.L("Editor.ProxiesOnly.ToTrash", Formatting.Count(plan.ToTrash)), asked.Detail!);
|
||||
Assert.Equal(originals, Directory.GetFiles(folder.OriginalsDirectory).Length, "nothing removed on Keep");
|
||||
Assert.True(menu.HoldsOriginals);
|
||||
|
||||
// Confirmed: every original the library holds goes, any other to the trash; the proxies stay.
|
||||
ui.ConfirmAnswer = true;
|
||||
command.Execute(null);
|
||||
await WorkspaceTestBed.UntilAsync(() => ui.Confirmations.Count == 2 && !command.IsRunning, "the removal");
|
||||
Assert.False(Directory.Exists(folder.OriginalsDirectory));
|
||||
Assert.Equal(Loc.L("Editor.Workspace.OriginalsRemoved"), ui.Toasts[^1].Title);
|
||||
Assert.False(menu.HoldsOriginals);
|
||||
Assert.False(menu.ProxiesOnlyCommand.CanExecute(null));
|
||||
Assert.Equal(Loc.L("Tooltips.Editor.Project.ProxiesAlready"), menu.ProxiesOnlyToolTip, "says why it is disabled");
|
||||
Assert.True(folder.ReadMedia()!.Frames.All(f => f.File is not null && File.Exists(folder.MediaFile(f.File))));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task SendAgainQueuesTheRendersNotSentAndOnlyThose()
|
||||
{
|
||||
await using var bed = await WorkspaceTestBed.CreateAsync(context, frames: 2);
|
||||
var host = bed.Host(new AppSettings { WorkspaceAutoSync = false });
|
||||
var projectId = await bed.CheckoutAsync(host);
|
||||
var folder = host.Store.Find(projectId)!;
|
||||
Assert.False(await host.SendRendersAsync(projectId, bed.Ct), "nothing waits to be sent");
|
||||
Assert.False(await host.RenderSendPendingAsync(projectId, bed.SequenceId, bed.Ct));
|
||||
|
||||
Directory.CreateDirectory(folder.ExportsDirectory);
|
||||
await File.WriteAllBytesAsync(Path.Combine(folder.ExportsDirectory, "clip.avi"), [1, 2, 3], bed.Ct);
|
||||
var entry = new WorkspaceRenderEntry(Guid.CreateVersion7(), Guid.CreateVersion7(), "clip.avi", new string('0', 64), 3, "Custom", "Mjpeg", 96, 64, 25, 0.16,
|
||||
projectId, null, null, DateTimeOffset.UtcNow);
|
||||
using (await folder.LockAsync(TimeSpan.FromSeconds(TestTiming.Budget(10)), bed.Ct)) folder.WriteRenders(WorkspaceRenders.Empty.With(entry.AsFailed("cut")));
|
||||
|
||||
// A send that failed leaves its render unsent: Send again queues one send of every such render.
|
||||
Assert.Equal(1, WorkspaceCleaner.UnsentRenders(folder));
|
||||
Assert.True(await host.SendRendersAsync(projectId, bed.Ct));
|
||||
var sends = (await bed.Db.Jobs.ListAsync(null, 50, null, bed.Ct)).Items.Where(j => j.Kind == JobKind.WorkspaceSend).ToList();
|
||||
Assert.Equal(1, sends.Count);
|
||||
var parameters = Assert.NotNull(WorkspaceJobs.SendParameters(sends[0]));
|
||||
Assert.Equal((projectId, host.Store.Root), (parameters.ProjectId, parameters.WorkspaceRoot));
|
||||
Assert.Empty(parameters.RenderIds);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task VersionOnRenderSavesAChangedProjectFirst()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user