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
This commit is contained in:
8 files changed
+150
-39
No files matched your search
@@ -65,18 +65,10 @@ public sealed class FrameRepository
|
||||
_db.ListAsync($"SELECT {Columns} FROM frames WHERE sequence_id = $1 AND idx > $2 ORDER BY idx LIMIT $3",
|
||||
[sequenceId, afterIndex, Cursor.ClampLimit(limit)], Map, cancellationToken);
|
||||
|
||||
/// <summary>Every frame with this content hash (duplicate detection).</summary>
|
||||
/// <summary>Every frame with this content hash (duplicate detection, upload short-circuit).</summary>
|
||||
public Task<IReadOnlyList<Frame>> FindBySha256Async(string sha256, CancellationToken cancellationToken = default) =>
|
||||
_db.ListAsync($"SELECT {Columns} FROM frames WHERE sha256 = $1 ORDER BY sequence_id, idx", [sha256.ToLowerInvariant()], Map, cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Frames with this content hash that are not flagged missing or corrupt: only such a copy may stand for an upload
|
||||
/// (the upload short-circuit, a commit settled after a crash), so an upload of the same content repairs a damaged one.
|
||||
/// </summary>
|
||||
public Task<IReadOnlyList<Frame>> FindIntactBySha256Async(string sha256, CancellationToken cancellationToken = default) =>
|
||||
_db.ListAsync($"SELECT {Columns} FROM frames WHERE sha256 = $1 AND (flags & $2) = 0 ORDER BY sequence_id, idx",
|
||||
[sha256.ToLowerInvariant(), (int)(FrameFlags.Missing | FrameFlags.Corrupt)], Map, cancellationToken);
|
||||
|
||||
/// <summary>Id and index of every frame of a sequence, in index order.</summary>
|
||||
public Task<IReadOnlyList<FramePosition>> ListPositionsAsync(Guid sequenceId, CancellationToken cancellationToken = default) =>
|
||||
_db.ListAsync("SELECT id, idx FROM frames WHERE sequence_id = $1 ORDER BY idx", [sequenceId], r => new FramePosition(r.GetGuid(0), r.GetInt32(1)),
|
||||
|
||||
Reference in new issue
Block a user