fix: address the phase 5 review
Video trash moves across volumes commit once the verified copy has its name and leave an undeletable source whole behind a .leftover marker that the next start settles; deletes rehash under the lease. Restores honour the names renders are writing, and encoders never overwrite an output. Routing floors at the stored settings' format, kindless stills read as stills, star trails restart per loop, and settings the encoder ignored become render warnings. The Videos section fits beside the player, plays downloaded server copies, names blocked videos and says why actions are off; the admin panel offers no download for sequences or missing files and names a filtered sequence from its record. Refs #21 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6d87a1bc6d
commit
1be273d0e4
38 files changed
+958
-160
No files matched your search
@@ -67,6 +67,35 @@ public sealed class VideoLibraryTests(TestContext context)
|
||||
Assert.True((await fx.Library.GetAsync(gif.Id, fx.Ct))!.Missing);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AStillWhoseKindWasLostIsStillAStill()
|
||||
{
|
||||
// A still a server of before phase 5 stored (and a PC then synced) has no kind: its image codec, fps 0 and duration 0 tell it.
|
||||
await using var fx = await VideoFixture.CreateAsync(context);
|
||||
var roof = await fx.SequenceAsync("Roof", 2);
|
||||
var kindless = new Render
|
||||
{
|
||||
Id = Guid.CreateVersion7(),
|
||||
SequenceId = roof.Id,
|
||||
PresetName = "PNG",
|
||||
OutputPath = "Roof/exports/roof - 0007.png",
|
||||
Codec = "PngSequence",
|
||||
Width = 96,
|
||||
Height = 64,
|
||||
Created = Day,
|
||||
};
|
||||
await fx.Db.Renders.InsertAsync(kindless, fx.Ct);
|
||||
var pngs = await fx.SequenceRenderAsync(roof, "roof-PNG", 2);
|
||||
|
||||
Assert.Equal(RenderKind.Still, RenderKind.Of(kindless));
|
||||
Assert.Equal(RenderKind.Sequence, RenderKind.Of(pngs), "an image sequence has a frame rate");
|
||||
async Task<List<Guid>> Ids(string kind) => [.. (await fx.Library.ListAsync(new VideoQuery { Kind = kind }, fx.Ct)).Items.Select(i => i.Render.Id)];
|
||||
Assert.SequenceEqual([kindless.Id], await Ids(RenderKind.Still));
|
||||
Assert.SequenceEqual([pngs.Id], await Ids(RenderKind.Sequence));
|
||||
Assert.Empty(await Ids(RenderKind.Video));
|
||||
Assert.Equal(RenderKind.Still, (await fx.Library.GetAsync(kindless.Id, fx.Ct))!.Kind);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TheDryRunFingerprintChangesWhenTheVideosDo()
|
||||
{
|
||||
@@ -208,4 +237,80 @@ public sealed class VideoLibraryTests(TestContext context)
|
||||
Assert.Equal((pngs.Id, (string?)null), (restored.Id, restored.Sha256));
|
||||
Assert.Equal(4, Directory.GetFiles(fx.FileOf(pngs)).Length);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[WindowsOnly]
|
||||
public async Task AFileHeldOpenWhileItIsCopiedToTheTrashStaysWholeUntilTheNextStart()
|
||||
{
|
||||
await using var fx = await VideoFixture.CreateAsync(context);
|
||||
var sequence = await fx.SequenceAsync();
|
||||
var render = await fx.RenderAsync(sequence, "sunset.mp4", 3000);
|
||||
var source = fx.FileOf(render);
|
||||
fx.Library.Trash.ForceCopy = true;
|
||||
var plan = await fx.Library.PlanDeleteAsync([render.Id], fx.Ct);
|
||||
|
||||
// A player holds the file open: it copies and verifies, but the original cannot be deleted.
|
||||
string name;
|
||||
using (new FileStream(source, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
name = (await fx.Library.DeleteAsync([render.Id], plan.Fingerprint, null, fx.Ct)).TrashEntries.Single();
|
||||
|
||||
// The delete is done (row gone, verified copy listed); the original stays whole and is marked as left over.
|
||||
var (folder, _) = VideoTrash.Location(fx.Archive.Paths, name);
|
||||
Assert.Null(await fx.Db.Renders.GetAsync(render.Id, fx.Ct));
|
||||
Assert.Equal(3000L, new FileInfo(Path.Combine(folder, "sunset.mp4")).Length);
|
||||
Assert.Equal(3000L, new FileInfo(source).Length);
|
||||
Assert.True(File.Exists(folder + VideoTrash.LeftoverSuffix));
|
||||
Assert.Equal(name, (await fx.Archive.Service.Trash.ListAsync(fx.Archive.Archive, fx.Ct)).Single(e => e.Kind == Chronos.Data.Archiving.TrashKind.Videos).Name);
|
||||
|
||||
// The next start removes it, and the render comes back under its own name.
|
||||
Assert.Equal(1, await fx.Library.RecoverAsync(fx.Archive.Archive, fx.Ct));
|
||||
Assert.False(File.Exists(source));
|
||||
Assert.False(File.Exists(folder + VideoTrash.LeftoverSuffix));
|
||||
Assert.Equal(render.OutputPath, (await fx.Library.RestoreAsync(fx.Archive.Archive.Id, name, fx.Ct)).OutputPath);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[WindowsOnly]
|
||||
public async Task AnImageSequenceWithAFileHeldOpenKeepsEveryFileUntilTheNextStart()
|
||||
{
|
||||
await using var fx = await VideoFixture.CreateAsync(context);
|
||||
var sequence = await fx.SequenceAsync();
|
||||
var pngs = await fx.SequenceRenderAsync(sequence, "clip-PNG", 4);
|
||||
var source = fx.FileOf(pngs);
|
||||
var files = Directory.GetFiles(source).Order(StringComparer.Ordinal).ToList();
|
||||
fx.Library.Trash.ForceCopy = true;
|
||||
var plan = await fx.Library.PlanDeleteAsync([pngs.Id], fx.Ct);
|
||||
|
||||
string name;
|
||||
using (new FileStream(files[2], FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
name = (await fx.Library.DeleteAsync([pngs.Id], plan.Fingerprint, null, fx.Ct)).TrashEntries.Single();
|
||||
|
||||
// Never half a folder: every file stays where it was, and every one is in the trash.
|
||||
var (folder, _) = VideoTrash.Location(fx.Archive.Paths, name);
|
||||
Assert.SequenceEqual(files, Directory.GetFiles(source).Order(StringComparer.Ordinal));
|
||||
Assert.Equal(4, Directory.GetFiles(Path.Combine(folder, Path.GetFileName(source))).Length);
|
||||
Assert.True(File.Exists(folder + VideoTrash.LeftoverSuffix));
|
||||
|
||||
Assert.Equal(1, await fx.Library.RecoverAsync(fx.Archive.Archive, fx.Ct));
|
||||
Assert.False(Directory.Exists(source));
|
||||
Assert.Empty(Directory.GetDirectories(Path.GetDirectoryName(source)!, ".*removing-*"));
|
||||
Assert.Equal(4, Directory.GetFiles(Path.Combine(folder, Path.GetFileName(source))).Length, "the trash keeps its copy");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ARestoreSkipsANameARenderIsWriting()
|
||||
{
|
||||
await using var fx = await VideoFixture.CreateAsync(context);
|
||||
var sequence = await fx.SequenceAsync();
|
||||
var render = await fx.RenderAsync(sequence, "sunset.mp4", 2000);
|
||||
var plan = await fx.Library.PlanDeleteAsync([render.Id], fx.Ct);
|
||||
var name = (await fx.Library.DeleteAsync([render.Id], plan.Fingerprint, null, fx.Ct)).TrashEntries.Single();
|
||||
|
||||
// A render of this process picked the free name meanwhile and is still encoding it.
|
||||
using var writing = new Chronos.Data.Processing.OutputNames();
|
||||
Assert.True(writing.TryReserve(fx.FileOf(render)));
|
||||
var restored = await fx.Library.RestoreAsync(fx.Archive.Archive.Id, name, fx.Ct);
|
||||
Assert.Equal("sunset (2).mp4", Path.GetFileName(restored.OutputPath));
|
||||
Assert.False(File.Exists(fx.FileOf(render)));
|
||||
}
|
||||
}
|
||||
@@ -50,10 +50,11 @@ public sealed class VideoRenderTests(TestContext context)
|
||||
// Only a batch preset plays back: the job of that preset needs format 3, the plain one does not.
|
||||
var split = ProcessingJobs.Split(Read(ProcessingJobs.Render(sequence, Mjpeg with { Batch = ["gif-preview"] }, 96, 64, new ProjectSettings())), 96, 64, new ProjectSettings());
|
||||
Assert.SequenceEqual([1, 1], split.Select(p => p.RequiredSettingsFormat));
|
||||
// Routed with settings whose own export plays back, the job's export (which does not) is what counts, and the other way round.
|
||||
// Routed with settings whose own export plays back, the job's export does not, but the settings text the node reads is
|
||||
// format 3: a node of format 2 could not parse it. The other way round, the job's export counts.
|
||||
var plain = Read(ProcessingJobs.Render(sequence, Mjpeg, 96, 64, new ProjectSettings()));
|
||||
var playing = new ProjectSettings { Export = Mjpeg with { Playback = Boomerang } };
|
||||
Assert.Equal(1, ProcessingJobs.Routed(plain, playing, 96, 64).RequiredSettingsFormat);
|
||||
Assert.Equal(ProjectSettings.PlaybackVersion, ProcessingJobs.Routed(plain, playing, 96, 64).RequiredSettingsFormat);
|
||||
var posted = Read(ProcessingJobs.Render(sequence, Mjpeg with { Playback = Boomerang }, 96, 64, new ProjectSettings())) with { RequiredSettingsFormat = 1 };
|
||||
Assert.Equal(ProjectSettings.PlaybackVersion, ProcessingJobs.Routed(posted, new ProjectSettings(), 96, 64).RequiredSettingsFormat);
|
||||
Assert.Equal(ProjectSettings.PlaybackVersion, ProcessingJobs.RequiredFormat(new ProjectSettings(), Mjpeg with { Batch = ["gif-preview"], Playback = Boomerang }, 96, 64));
|
||||
@@ -124,7 +125,8 @@ public sealed class VideoRenderTests(TestContext context)
|
||||
var set = new SequenceFrames(sequence, frames, frames.Select(f => (string?)f.RelativePath).ToList());
|
||||
Assert.Equal(3, SequenceRender.StillIndex(set, 1, new string('d', 64)));
|
||||
Assert.Equal(3, SequenceRender.StillIndex(set, 1, new string('D', 64)), "any case");
|
||||
Assert.Equal(1, SequenceRender.StillIndex(set, 1, new string('z', 64)), "a photo no longer there: the index");
|
||||
Assert.Null(SequenceRender.StillIndex(set, 1, new string('z', 64)), "a photo no longer there: its index names another photo now");
|
||||
Assert.Equal(1, SequenceRender.StillIndex(set, 1, null), "no hash: the index");
|
||||
Assert.Null(SequenceRender.StillIndex(set, 9, null));
|
||||
// Named by the export's template and the frame number from 1; a taken name gets " (2)".
|
||||
var folder = context.CreateTempDirectory("still");
|
||||
|
||||
Reference in new issue
Block a user