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
@@ -20,8 +20,9 @@ namespace Chronos.Data.Processing.Jobs;
|
||||
/// preset render after one preparation pass into the sequence's <c>exports/</c> (or the export folder, never on a
|
||||
/// server), named by the template without taking a name another render of this process is writing, and each finished
|
||||
/// output is recorded at once (its row id derives from the job and the entry, so every attempt knows what is recorded).
|
||||
/// Checkpoint: the entries recorded and the output being written, so a crashed attempt's leftovers are removed and only
|
||||
/// unfinished entries render again. A failed entry fails the job after the others ran; retrying renders it alone. A
|
||||
/// Checkpoint: the entries recorded and the output being written, so a crashed attempt's leftovers are removed (where a
|
||||
/// Reorganize took them since, never in the folder the sequence left, <see cref="Leftover"/>) and only unfinished entries
|
||||
/// render again. A failed entry fails the job after the others ran; retrying renders it alone. A
|
||||
/// sequence whose folder is not where the index has it (another index moved it, until this index's next scan; the folder
|
||||
/// it left may hold another sequence now) is refused.
|
||||
/// </summary>
|
||||
@@ -59,7 +60,8 @@ internal sealed class RenderJobHandler(ChronosDatabase db, ProcessingOptions opt
|
||||
{
|
||||
if (!done.Contains(i) && await db.Renders.GetAsync(RenderId(context.Job.Id, i), cancellation).ConfigureAwait(false) is not null) done.Add(i);
|
||||
}
|
||||
if (resume is { Pending: { } pending, PendingOutput: { } output } && !done.Contains(pending) && names.TryReserve(output))
|
||||
if (resume is { Pending: { } pending, PendingOutput: { } chosen } && !done.Contains(pending)
|
||||
&& Leftover(paths, folder, resume.Folder, chosen) is { } output && names.TryReserve(output))
|
||||
{
|
||||
// Unless another render recorded that name since (the output did not exist yet when it chose it).
|
||||
var recorded = await db.Renders.ListBySequenceAsync(sequence.Id, cancellation).ConfigureAwait(false);
|
||||
@@ -78,7 +80,7 @@ internal sealed class RenderJobHandler(ChronosDatabase db, ProcessingOptions opt
|
||||
outcomes = await render.RenderAllAsync(
|
||||
targets,
|
||||
(target, setup) => names.Reserve(taken => ExportNaming.OutputPath(project.Export, folder.Exports, SequenceRender.NameContext(sequence, target, setup), taken)),
|
||||
(index, path) => context.CheckpointAsync(new RenderCheckpoint(done, index, path).ToJson(), context.Done, context.Total),
|
||||
(index, path) => context.CheckpointAsync(new RenderCheckpoint(done, index, path, sequence.Folder).ToJson(), context.Done, context.Total),
|
||||
async (index, target, result) =>
|
||||
{
|
||||
// The output is complete: record it even if the job is being cancelled, so it is never orphaned.
|
||||
@@ -149,6 +151,24 @@ internal sealed class RenderJobHandler(ChronosDatabase db, ProcessingOptions opt
|
||||
return new Guid(hash[..16], bigEndian: true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Where the output a crashed attempt was writing is now, for its leftovers to be removed: among the exports of the
|
||||
/// sequence's folder (the one the index has now, which holds the sequence; one chosen in the folder the sequence had
|
||||
/// before a Reorganize moved it is where the folder took it), or in an export folder chosen on a client outside the
|
||||
/// archive. Null, and the leftovers stay, for one anywhere else in the archive: an export folder chosen in it, or the
|
||||
/// exports of a folder the sequence left, which may hold another sequence now with its own export of that name.
|
||||
/// </summary>
|
||||
/// <param name="chosenIn">The sequence's archive-relative folder when the attempt chose the output; null when unknown.</param>
|
||||
private static string? Leftover(ArchivePaths paths, SequencePaths folder, string? chosenIn, string output)
|
||||
{
|
||||
var relative = paths.ToRelative(output);
|
||||
if (relative.StartsWith("..", StringComparison.Ordinal) || Path.IsPathRooted(relative)) return output;
|
||||
var cut = relative.LastIndexOf('/');
|
||||
var (parent, name) = (cut < 0 ? string.Empty : relative[..cut], relative[(cut + 1)..]);
|
||||
if (parent == paths.ToRelative(folder.Exports)) return output;
|
||||
return chosenIn is not null && parent == paths.ToRelative(paths.Sequence(chosenIn).Exports) ? Path.Combine(folder.Exports, name) : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes what an interrupted attempt left of <paramref name="output"/>: the encoder's hidden temporary file or
|
||||
/// folder, and an output that was completed but never recorded (it renders again under the same name).
|
||||
|
||||
Reference in new issue
Block a user