fix(archive): a third sequence's export follows its file; resumed renders and restored originals stay out of folders a sequence left
Round 5 stopped clearing "behind" for rows of a third sequence (neither the one moving nor the one now holding the old folder). Such a row, an export one sequence saved in another's exports through the Export folder picker, then stayed at its old path whenever the sequence that moved into the folder brought an export of the same name, and named that sequence's file (Send exports would upload it). A file at the old path is never "behind" while the old folder holds another sequence: it is that sequence's, so every row other than the holder's follows its file. A resumed render job deleted the output its crashed attempt was writing at the absolute path in the checkpoint. After another index moved the sequence away and another sequence into the folder it left, and this index scanned, that path named the other sequence's export. The checkpoint now keeps the sequence's folder when the output was chosen; a pending output there is rebased into the folder the sequence is in now, one in the sequence's current exports or outside the archive (an export folder chosen on a client) is discarded as before, and one anywhere else in the archive is left alone (the entry renders under another name). Older checkpoints, without the folder, only discard in the current exports. Download originals put an original flagged missing back at the path read before the transfer, with no lease and no check of the folder: after another index moved the sequence, it recreated the folder it left or filed the photo among another sequence's originals. The restores now run after the transfers under the sequence's lease, in the folder the index has then, which must hold the sequence (SequenceFolders.Holds), at each frame's path read under that lease. Otherwise nothing is restored, the copies stay staged for the next attempt and the job fails with Errors.Archive.FolderMoved after its other work. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit ad46ef68180845de4b9b605a4ce2529a148c6f13)
This commit is contained in:
1 parent
23403f1c07
commit
f8c445fac3
7 files changed
+210
-29
No files matched your search
@@ -375,6 +375,50 @@ public sealed class RenderJobTests(TestContext context)
|
||||
Assert.Count(2, await fx.Db.Renders.ListBySequenceAsync(sequence.Id, fx.Ct));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ARenderResumedAfterItsFolderMovedNeverDeletesWhatAnotherSequenceBroughtIntoIt()
|
||||
{
|
||||
// The crashed attempt's checkpoint names the folder it chose the output in, or (written by an older version) does not.
|
||||
foreach (var named in new[] { true, false })
|
||||
{
|
||||
await using var fx = await ProcessingFixture.CreateAsync(context);
|
||||
var sequence = await fx.AddAsync(Scene());
|
||||
var stranger = await fx.AddAsync(Scene(), "Other");
|
||||
var output = Path.Combine(fx.Folder(sequence).Exports, "clip-MJPEG.avi");
|
||||
// The crashed attempt left its encoder's temporary file and a finished output it never recorded; the other
|
||||
// sequence has an export of that name, and a hidden file that looks like such a leftover.
|
||||
Directory.CreateDirectory(fx.Folder(sequence).Exports);
|
||||
await File.WriteAllBytesAsync(Path.Combine(fx.Folder(sequence).Exports, ".clip-MJPEG.avi.0badf00d.tmp"), new byte[100], fx.Ct);
|
||||
await File.WriteAllBytesAsync(output, new byte[100], fx.Ct);
|
||||
Directory.CreateDirectory(fx.Folder(stranger).Exports);
|
||||
await File.WriteAllBytesAsync(Path.Combine(fx.Folder(stranger).Exports, ".clip-MJPEG.avi.0ddba11.tmp"), new byte[50], fx.Ct);
|
||||
await File.WriteAllBytesAsync(Path.Combine(fx.Folder(stranger).Exports, "clip-MJPEG.avi"), Encoding.ASCII.GetBytes("RIFF theirs"), fx.Ct);
|
||||
|
||||
// Another index moves the folder away, the leftovers along, then the other sequence into the folder it left; this
|
||||
// index's scan finds both before the job resumes.
|
||||
var (server, archive) = await fx.Archive.OtherWriterAsync();
|
||||
var plan = await server.PlanRenameAsync(archive.Id, [sequence.Id], "Moved/{date}", null, fx.Ct);
|
||||
await server.ApplyRenameAsync(plan, null, fx.Ct);
|
||||
await server.ApplyRenameAsync(await server.PlanRenameAsync(archive.Id, [stranger.Id], sequence.Folder, null, fx.Ct), null, fx.Ct);
|
||||
await fx.Archive.ScanAsync();
|
||||
var before = ArchiveFixture.FilesOf(fx.Folder(sequence).Folder);
|
||||
await fx.StartEngineAsync();
|
||||
|
||||
var job = await fx.Archive.EnqueueWithCheckpointAsync(fx.Engine, ProcessingJobs.Render(sequence, Mjpeg, 96, 64),
|
||||
new RenderCheckpoint([], 0, output, named ? sequence.Folder : null).ToJson());
|
||||
await fx.WaitForAsync(job.Id, JobState.Done);
|
||||
|
||||
Assert.SequenceEqual(before, ArchiveFixture.FilesOf(fx.Folder(sequence).Folder), $"{named}: the other sequence's files are untouched");
|
||||
// Its leftovers are removed where the folder took them when the checkpoint says where it chose the output, and
|
||||
// stay otherwise: the render then takes another name.
|
||||
var moved = fx.Archive.Paths.Sequence(plan.Steps.Single().ToFolder).Exports;
|
||||
Assert.SequenceEqual(named ? ["clip-MJPEG.avi"] : [".clip-MJPEG.avi.0badf00d.tmp", "clip-MJPEG (2).avi", "clip-MJPEG.avi"], Entries(moved), named.ToString());
|
||||
var rendered = (await fx.Db.Renders.ListBySequenceAsync(sequence.Id, fx.Ct)).Single().OutputPath;
|
||||
Assert.Equal(plan.Steps.Single().ToFolder + (named ? "/exports/clip-MJPEG.avi" : "/exports/clip-MJPEG (2).avi"), rendered);
|
||||
Assert.Equal("RIFF", Encoding.ASCII.GetString((await File.ReadAllBytesAsync(fx.Archive.Paths.FromRelative(rendered), fx.Ct))[..4]));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ConcurrentRendersOfOnePresetKeepBothOutputs()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user