A sequence created with POST /api/v1/sequences had no folder, and the ingest looked for its sidecar at the archive root: every upload into it failed with 503 commit_failed, so the Uploader's "New sequence" target never worked. Its first frame now claims a folder by the rules of a sequence created by an upload (folder template with its title, unique variant, sidecar with the row's id, title, tags, rating, notes and project), and the row takes the folder in one transaction (DOCKER-1). A frame flagged missing or corrupt, or whose file is gone or has another size, no longer stands for an upload: the start short-circuit and crash recovery match only intact frames still on disk, and the ingest repairs such a frame with the verified copy (same id and position, flags cleared, a damaged file kept beside it as name.damaged-<time>) instead of calling it a duplicate. The Uploader deletes a source only after the server received and verified its bytes in that upload, never on "already on the server" (SRV-1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
34 lines
1.4 KiB
C#
34 lines
1.4 KiB
C#
namespace Titano.Data.Archiving;
|
|
|
|
/// <summary>
|
|
/// A verified file waiting in a staging folder on the archive volume, ready to become a frame (BRIEF §4.3, §14.4).
|
|
/// Exactly one of <see cref="SequenceId"/>, <see cref="NewSequenceTitle"/> or <see cref="SessionKey"/> selects the target:
|
|
/// an existing sequence, a new one with that title, or the sequence grouped automatically by session.
|
|
/// </summary>
|
|
public sealed record IngestRequest(
|
|
Guid ArchiveId,
|
|
Guid? SequenceId,
|
|
string? NewSequenceTitle,
|
|
string? SessionKey,
|
|
string StagedPath,
|
|
string OriginalFileName,
|
|
long Size,
|
|
string Sha256,
|
|
DateTime? ClientCapturedAt,
|
|
Guid? UserId);
|
|
|
|
/// <summary>
|
|
/// The committed frame; <see cref="Duplicate"/> when an intact frame of the sequence already held that SHA-256 (the file
|
|
/// stays in staging). A frame with that SHA-256 that was missing or damaged is repaired with the file instead (not a duplicate).
|
|
/// </summary>
|
|
public sealed record IngestResult(Guid SequenceId, Guid FrameId, int Index, string RelativePath, bool Duplicate);
|
|
|
|
/// <summary>
|
|
/// Commits staged files into the archive layout (originals folder, naming templates, <c>sequence.json</c> written
|
|
/// atomically) and the index. Used by the server's upload completion and by the client's card import.
|
|
/// </summary>
|
|
public interface IArchiveIngest
|
|
{
|
|
Task<IngestResult> CommitAsync(IngestRequest request, CancellationToken cancellationToken = default);
|
|
}
|