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
@@ -143,6 +143,7 @@ public sealed class ArchiveIngestTests(TestContext context)
|
||||
var repaired = await fx.Service.Ingest.CommitAsync(Request(fx, again), fx.Ct);
|
||||
|
||||
Assert.False(repaired.Duplicate, "the server holds no intact copy: this one is filed");
|
||||
Assert.Equal((false, true), (original.Repaired, repaired.Repaired));
|
||||
Assert.Equal((original.FrameId, original.Index, original.RelativePath), (repaired.FrameId, repaired.Index, repaired.RelativePath));
|
||||
Assert.SequenceEqual(bytes, await File.ReadAllBytesAsync(file, fx.Ct));
|
||||
Assert.FileMissing(again.Path);
|
||||
@@ -172,7 +173,7 @@ public sealed class ArchiveIngestTests(TestContext context)
|
||||
|
||||
var repaired = await fx.Service.Ingest.CommitAsync(Request(fx, fx.Stage(Start, 7)), fx.Ct);
|
||||
|
||||
Assert.False(repaired.Duplicate);
|
||||
Assert.Equal((false, true), (repaired.Duplicate, repaired.Repaired));
|
||||
Assert.Equal(original.FrameId, repaired.FrameId);
|
||||
Assert.SequenceEqual(bytes, await File.ReadAllBytesAsync(file, fx.Ct));
|
||||
var aside = Directory.GetFiles(Path.GetDirectoryName(file)!, Path.GetFileName(file) + ".damaged-*");
|
||||
@@ -220,6 +221,27 @@ public sealed class ArchiveIngestTests(TestContext context)
|
||||
Assert.Equal(0, (await fx.ScanAsync()).Indexed);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ASequenceAdoptedAtTheRootIsNeverMovedWhenItsSidecarIsGone()
|
||||
{
|
||||
await using var fx = await CreateAsync(context);
|
||||
Photos.WriteSeries(fx.Archive.RootPath, Start, 2);
|
||||
await fx.ScanAsync();
|
||||
var adopted = Assert.NotNull((await fx.Db.Sequences.ListLocationsAsync(fx.Archive.Id, fx.Ct)).SingleOrDefault());
|
||||
Assert.Equal(string.Empty, adopted.Folder);
|
||||
File.Delete(fx.Paths.Sequence(string.Empty).ManifestPath);
|
||||
|
||||
// It held photos, so it is no sequence waiting for a folder: the commit reports the missing sidecar.
|
||||
var staged = fx.Stage(Start.AddMinutes(5), 3);
|
||||
await Assert.ThrowsAsync<IOException>(() => fx.Service.Ingest.CommitAsync(Request(fx, staged, sequenceId: adopted.Id), fx.Ct));
|
||||
|
||||
var row = (await fx.Db.Sequences.GetAsync(adopted.Id))!;
|
||||
Assert.Equal((string.Empty, 2), (row.Folder, row.FrameCount));
|
||||
Assert.Count(2, await fx.Db.Frames.ListBySequenceAsync(adopted.Id));
|
||||
Assert.False(Directory.Exists(Path.Combine(fx.Archive.RootPath, "2026")), "no folder was claimed for it");
|
||||
Assert.FileExists(staged.Path);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task FramesInsertedBeforeOthersTakeTheProjectPositionsAlong()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user