Files
Chronos/src/Titano.Data/Archiving/IArchiveIngest.cs
T
Claude 886132b5bb fix(upload): repairs charge no quota and another sequence's copy no longer blocks them
A re-upload that repairs a missing or damaged frame is now reported as
IngestResult.Repaired and adds nothing to the uploader's used bytes; the
quota checks at start and completion skip uploads whose target sequence
already holds the content. The start shortcut and crash recovery share
one rule (UploadRules.StandIn): an intact copy stands for the upload, the
target sequence's own copy first, except when the target holds the
content only in damaged copies, which the upload's bytes then repair.
A sequence adopted at the archive root that holds frames is never given
a new folder when its root sidecar is missing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
2026-10-12 10:53:49 +00:00

35 lines
1.5 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:
/// <see cref="Repaired"/>, not a duplicate, and the archive holds no more bytes than before.
/// </summary>
public sealed record IngestResult(Guid SequenceId, Guid FrameId, int Index, string RelativePath, bool Duplicate, bool Repaired = false);
/// <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);
}