fix(ingest): file uploads into API-made sequences and repair damaged frames

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
This commit is contained in:
Claude committed 2026-10-12 09:40:27 +00:00
1 parent 23308c77dd
commit 94b13cc064
12 files changed
+441 -41

No files matched your search

@@ -33,7 +33,7 @@ public sealed class UploadEngineTests(TestContext context)
});
[Test]
public void DeleteAfterUploadRemovesOnlyConfirmedUnchangedFiles() => SingleThreadedContext.Run(async () =>
public void DeleteAfterUploadRemovesOnlyVerifiedUnchangedFiles() => SingleThreadedContext.Run(async () =>
{
var queue = Queue(UploadTargetMode.Sessions, 3);
var (verified, existing, changed) = (queue.Items[0], queue.Items[1], queue.Items[2]);
@@ -54,7 +54,8 @@ public sealed class UploadEngineTests(TestContext context)
Assert.Equal(UploadItemState.Skipped, existing.State);
Assert.False(File.Exists(verified.Path));
Assert.False(File.Exists(existing.Path));
// The server matched its hash without receiving these bytes: no verified copy, so the source stays.
Assert.True(File.Exists(existing.Path), "a file the server already held is kept");
Assert.True(File.Exists(changed.Path), "a file changed after verification is kept");
});