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>
121 lines
5.5 KiB
C#
121 lines
5.5 KiB
C#
using Chronos.App.Editor;
|
|
using Chronos.Core.Model;
|
|
using Chronos.Testing;
|
|
|
|
namespace Chronos.App.Tests.Editor;
|
|
|
|
/// <summary>The jobs of the open sequence: the busy lock, Analyse queued twice, and the server job the header shows.</summary>
|
|
public sealed class SequenceJobsTests
|
|
{
|
|
private static readonly Guid Sunset = Guid.CreateVersion7();
|
|
|
|
[Test]
|
|
public void OnlyAnalysesAndRendersOfTheSequenceCount()
|
|
{
|
|
var jobs = new SequenceJobs(Sunset);
|
|
Assert.False(jobs.Track(Job(JobKind.Render, JobState.Running, Guid.CreateVersion7())), "another sequence");
|
|
Assert.False(jobs.Track(Job(JobKind.Proxies, JobState.Running)), "not an analysis or a render");
|
|
Assert.Null(jobs.Shown);
|
|
Assert.False(jobs.IsBusy);
|
|
}
|
|
|
|
[Test]
|
|
public void StatesChangeTheLockProgressAloneDoesNot()
|
|
{
|
|
var jobs = new SequenceJobs(Sunset);
|
|
var render = Job(JobKind.Render, JobState.Queued);
|
|
Assert.True(jobs.Track(render), "joined");
|
|
Assert.True(jobs.IsActive(render.Id));
|
|
Assert.False(jobs.IsBusy, "waiting does not lock the settings");
|
|
|
|
Assert.True(jobs.Track(render with { State = JobState.Running }), "started");
|
|
Assert.True(jobs.IsBusy);
|
|
Assert.False(jobs.Track(render with { State = JobState.Running, ProgressDone = 40, ProgressTotal = 96 }), "progress only");
|
|
Assert.Equal(40, jobs.Shown!.ProgressDone);
|
|
|
|
Assert.True(jobs.Track(render with { State = JobState.Paused }));
|
|
Assert.False(jobs.IsBusy, "a paused render holds nothing");
|
|
Assert.True(jobs.Track(render with { State = JobState.Failed }), "left");
|
|
Assert.False(jobs.IsActive(render.Id));
|
|
Assert.False(jobs.Track(render with { State = JobState.Failed }), "an ended job that is not tracked changes nothing");
|
|
}
|
|
|
|
[Test]
|
|
public void AnAnalysisWaitingOrPausedStillCountsAsQueued()
|
|
{
|
|
var jobs = new SequenceJobs(Sunset);
|
|
var analysis = Job(JobKind.DeepAnalyse, JobState.Paused);
|
|
jobs.Track(analysis);
|
|
Assert.True(jobs.IsAnalysing, "Analyse would queue a second one");
|
|
jobs.Track(analysis with { State = JobState.Done });
|
|
Assert.False(jobs.IsAnalysing);
|
|
}
|
|
|
|
[Test]
|
|
public void TheHeaderShowsTheRunningJobThenThePausedThenTheOldestWaiting()
|
|
{
|
|
var jobs = new SequenceJobs(Sunset);
|
|
var now = DateTimeOffset.UtcNow;
|
|
var later = Job(JobKind.Render, JobState.Queued) with { Created = now };
|
|
var first = Job(JobKind.Render, JobState.Queued) with { Created = now.AddMinutes(-5) };
|
|
var paused = Job(JobKind.DeepAnalyse, JobState.Paused) with { Created = now.AddMinutes(-9), Started = now.AddMinutes(-8) };
|
|
var running = Job(JobKind.Render, JobState.Running) with { Created = now.AddMinutes(-1), Started = now };
|
|
foreach (var job in new[] { later, first }) jobs.Track(job);
|
|
Assert.Equal(first.Id, jobs.Shown!.Id);
|
|
jobs.Track(paused);
|
|
Assert.Equal(paused.Id, jobs.Shown!.Id);
|
|
jobs.Track(running);
|
|
Assert.Equal(running.Id, jobs.Shown!.Id);
|
|
jobs.Track(running with { State = JobState.Done });
|
|
Assert.Equal(paused.Id, jobs.Shown!.Id);
|
|
}
|
|
|
|
[Test]
|
|
public void EachStepFollowsTheRunningJobOfItsKindThenThePausedThenTheOldestWaiting()
|
|
{
|
|
var jobs = new SequenceJobs(Sunset);
|
|
var now = DateTimeOffset.UtcNow;
|
|
var waiting = Job(JobKind.DeepAnalyse, JobState.Queued) with { Created = now.AddMinutes(-9) };
|
|
var paused = Job(JobKind.DeepAnalyse, JobState.Paused) with { Created = now.AddMinutes(-1), Started = now.AddMinutes(-1) };
|
|
var render = Job(JobKind.Render, JobState.Running) with { Started = now };
|
|
Assert.Null(jobs.Active(JobKind.DeepAnalyse));
|
|
jobs.Track(waiting);
|
|
Assert.Equal(waiting.Id, jobs.Active(JobKind.DeepAnalyse)!.Id);
|
|
jobs.Track(paused);
|
|
Assert.Equal(paused.Id, jobs.Active(JobKind.DeepAnalyse)!.Id, "a paused one before a waiting one");
|
|
jobs.Track(render);
|
|
Assert.Equal(paused.Id, jobs.Active(JobKind.DeepAnalyse)!.Id, "the running render is of another kind");
|
|
Assert.Equal(render.Id, jobs.Active(JobKind.Render)!.Id);
|
|
jobs.Track(waiting with { State = JobState.Running, Started = now });
|
|
Assert.Equal(waiting.Id, jobs.Active(JobKind.DeepAnalyse)!.Id, "a running one first");
|
|
Assert.Null(jobs.Active(JobKind.LightAnalyse));
|
|
}
|
|
|
|
[Test]
|
|
public void TheServerHeaderNeverShowsAWorkspaceRenderOrSendOfThisPc()
|
|
{
|
|
var jobs = new SequenceJobs(Sunset);
|
|
var now = DateTimeOffset.UtcNow;
|
|
var local = Job(JobKind.WorkspaceRender, JobState.Running) with { Started = now };
|
|
var send = Job(JobKind.WorkspaceSend, JobState.Queued);
|
|
jobs.Track(local);
|
|
jobs.Track(send);
|
|
Assert.Equal(local.Id, jobs.Shown!.Id, "the editor follows it");
|
|
Assert.Null(jobs.ShownAtHome, "the server header and its Cancel do not");
|
|
var atHome = Job(JobKind.DeepAnalyse, JobState.Queued) with { Created = now.AddMinutes(-3) };
|
|
jobs.Track(atHome);
|
|
Assert.Equal(atHome.Id, jobs.ShownAtHome!.Id, "a job at the home waits behind the local render, and is the one shown");
|
|
Assert.True(SequenceJobs.IsLocalKind(JobKind.WorkspaceSend));
|
|
Assert.False(SequenceJobs.IsLocalKind(JobKind.Render));
|
|
}
|
|
|
|
private static Job Job(JobKind kind, JobState state, Guid? target = null) => new()
|
|
{
|
|
Id = Guid.CreateVersion7(),
|
|
Kind = kind,
|
|
TargetIds = [target ?? Sunset],
|
|
State = state,
|
|
Created = DateTimeOffset.UtcNow,
|
|
};
|
|
}
|