feat(P2): videos library, verified video trash and copy job, render hashes and still jobs

Renders now record their SHA-256 and kind, so copies, deletes and restores can
be verified. The new videos library lists every render with paging and
filters, deletes into the archive trash after a dry run whose fingerprint must
still match (journalled, so a crash mid-move is settled on open), restores by id
refusing a tampered file, and a VideoCopy job copies renders hash-verified into
a videos folder outside the archive, never overwriting. A still job saves one
frame as an image through an interim Data-side path until P1's Core still API
lands. Batch exports keep the playback and routing uses the job's own export,
so a playback job needs settings format 3 and an older node never claims it.

Refs #21

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-05 02:27:37 +01:00
1 parent d472dfdec1
commit 03b4d0ef60
23 files changed
+2123 -72

No files matched your search

+25 -4
View File
@@ -47,6 +47,7 @@ public sealed class ArchiveService : IJobHandlerProvider
FrameTrash = new FrameTrash(db, _writer, Indexer, Ingest, Trash);
Converter = new MassConverter(db, _writer, Ingest, FrameTrash, Trash, this);
Projects = new ProjectService(db, _writer);
Videos = new Chronos.Data.Videos.VideoLibrary(db, _writer);
var shared = Housekeeping.CleanupSteps.Shared(Trash);
CleanupSteps = [.. shared, .. _writer.Options.CleanupSteps.Where(s => !shared.Any(o => o.Name == s.Name))];
}
@@ -70,9 +71,9 @@ public sealed class ArchiveService : IJobHandlerProvider
/// <summary>
/// The videos library of this index (owner review 1, R9): every render listed, deleted into the trash, restored and copied
/// into a videos folder. The groundwork stub until the library lands (<see cref="Chronos.Data.Videos.IVideoLibrary.IsAvailable"/> false).
/// into a videos folder (<see cref="JobKind.VideoCopy"/>, among <see cref="CreateJobHandlers"/>).
/// </summary>
public Chronos.Data.Videos.IVideoLibrary Videos { get; } = Chronos.Data.Videos.NotImplementedVideoLibrary.Instance;
public Chronos.Data.Videos.VideoLibrary Videos { get; }
/// <summary>Converts sequences to JPEG, TIFF-16 or linear DNG, replacing their frames or into new sequences (owner review 2, R7).</summary>
public MassConverter Converter { get; }
@@ -117,6 +118,7 @@ public sealed class ArchiveService : IJobHandlerProvider
new EmptyTrashJobHandler(_db, Trash),
new MoveJobHandler(_db, Renamer, _writer.Options.SequenceChanged),
new ConvertJobHandler(_db, Converter, _writer.Options.SequenceChanged),
new Chronos.Data.Videos.VideoCopyJobHandler(_db, Videos),
];
/// <summary>Makes <paramref name="root"/> a new, empty archive and indexes it.</summary>
@@ -172,6 +174,15 @@ public sealed class ArchiveService : IJobHandlerProvider
// The journal stays; the next open tries again. The archive itself is usable meanwhile (a server starts all the same).
Log.Warning("archive", $"Resuming an interrupted rename in {paths.Root} failed", ex);
}
try
{
// A delete of videos into the trash a crash interrupted completes, or is undone (owner review 1, R9).
await Videos.RecoverAsync(archive, cancellationToken).ConfigureAwait(false);
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or LeaseUnavailableException or DatabaseException)
{
Log.Warning("archive", $"Settling an interrupted delete of videos in {paths.Root} failed", ex);
}
return archive;
}
@@ -515,10 +526,13 @@ public sealed class ArchiveService : IJobHandlerProvider
(await RestoreEntryAsync(archiveId, entryName, null, cancellationToken).ConfigureAwait(false)).Sequence;
/// <summary>
/// Brings a trash entry back: a sequence into its folder (<see cref="SequenceTrash.RestoreAsync"/>), or photos into
/// Brings a trash entry back: a sequence into its folder (<see cref="SequenceTrash.RestoreAsync"/>), photos into
/// their sequence (<see cref="Archiving.FrameTrash.RestoreAsync"/>, which queues on <paramref name="followUps"/> what the
/// frames need again).
/// frames need again), or a video into its sequence's renders (<see cref="Chronos.Data.Videos.VideoLibrary.RestoreAsync"/>, owner
/// review 1, R9: <see cref="TrashRestoreResult.Sequence"/> is the video's).
/// </summary>
/// <exception cref="Chronos.Data.Videos.VideoLibraryException">A video entry whose file no longer matches its record, or whose sequence
/// is not in the index; nothing moved.</exception>
/// <exception cref="DirectoryNotFoundException">The entry is not in the trash.</exception>
/// <exception cref="SequenceInLibraryException">A sequence entry whose sequence is in the index already.</exception>
/// <exception cref="TrashMismatchException">No file of a photo entry matches its record; nothing moved.</exception>
@@ -528,6 +542,13 @@ public sealed class ArchiveService : IJobHandlerProvider
CancellationToken cancellationToken = default)
{
var archive = await LoadArchiveAsync(archiveId, cancellationToken).ConfigureAwait(false);
if (Chronos.Data.Videos.VideoTrashNames.IsEntryName(entryName))
{
var render = await Videos.RestoreAsync(archive.Id, entryName, cancellationToken).ConfigureAwait(false);
var owner = await _db.Sequences.GetAsync(render.SequenceId, CancellationToken.None).ConfigureAwait(false)
?? throw new InvalidOperationException($"The sequence of render {render.Id} is not in the index.");
return new TrashRestoreResult(TrashKind.Videos, owner, 0, [], false);
}
if (!Archiving.FrameTrash.IsPhotoEntry(entryName))
return new TrashRestoreResult(TrashKind.Sequence, await Trash.RestoreAsync(archive, entryName, cancellationToken).ConfigureAwait(false), 0, [], false);
var photos = await FrameTrash.RestoreAsync(archive, entryName, followUps, cancellationToken).ConfigureAwait(false);