fix(sync): keep project positions on their photos when settings cross copies
Settings synced between a PC and its server sequence were stored as they
came, in the other copy's frame order. When the inserted photos arrived
later (a download, an upload), the index moved those already-correct
positions a second time, so exclusions, the hero and camera keyframes
landed on other photos (V-21, CD-2).
- Settings are translated by photo (SHA-256, else size and capture time)
to the frames of the copy they go to: the server's before they are
compared or applied here, this PC's to the server's frames as its
manifest lists them before a push (SyncPositions).
- A position on a photo the receiving copy lacks waits in project.json as
a pending frame and takes its place when the photo arrives, on an
insertion or an append in step with the index; the Library's hero
frame follows. A hero chosen meanwhile wins, and advice does not fill
a hero while one waits. Old projects without the member are unchanged.
- Pushes send expectedFramesVersion; PATCH /api/v1/sequences/{id} answers
409 frames_conflict when the frames changed since, and the next
comparison translates again.
- A pulled payload equal to the local copy is settled without the
archive: an offline or read-only archive no longer fails the
comparison (V-10).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
25 files changed
+1091
-51
No files matched your search
@@ -276,6 +276,51 @@ public sealed class ArchiveIngestTests(TestContext context)
|
||||
Assert.True(JsonNode.DeepEquals(JsonNode.Parse(row.SettingsJson!), JsonNode.Parse(File.ReadAllText(folder.ProjectPath))), "project.json mirrors the index");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task PositionsWaitingForTheirPhotosTakeTheirPlaceWhenTheyArrive()
|
||||
{
|
||||
await using var fx = await CreateAsync(context);
|
||||
var results = new List<IngestResult>();
|
||||
for (var i = 0; i < 3; i++) results.Add(await fx.Service.Ingest.CommitAsync(Request(fx, fx.Stage(Start.AddMinutes(1 + i), 30 + i)), fx.Ct));
|
||||
var sequenceId = results[0].SequenceId;
|
||||
var folder = fx.Paths.Sequence((await fx.Db.Sequences.GetAsync(sequenceId))!.Folder);
|
||||
// Settings synced from a copy that also holds an earlier and a later photo: what names them waits for them.
|
||||
var early = fx.Stage(Start, 40);
|
||||
var late = fx.Stage(Start.AddMinutes(9), 41);
|
||||
var project = new ProjectSettings
|
||||
{
|
||||
ExcludedFrames = [1],
|
||||
Camera = new CameraSettings { Keyframes = [new CameraKey(0, 0.5, 0.5, 1, 0)] },
|
||||
PendingFrames =
|
||||
[
|
||||
new PendingFrame { Sha256 = early.Sha256, Size = early.Size, Excluded = true },
|
||||
new PendingFrame { Sha256 = late.Sha256, Size = late.Size, Hero = true, Keyframes = [new CameraKey(0, 0.3, 0.6, 2, 0)] },
|
||||
],
|
||||
}.ToJson();
|
||||
AtomicFile.WriteAllText(folder.ProjectPath, project);
|
||||
var version = (await fx.Db.Sequences.EditAsync(sequenceId, new SequenceEdit { SettingsJson = project }, null, fx.Ct)).Sequence!.SettingsVersion;
|
||||
|
||||
// The later photo is appended in step with the index; the earlier one is inserted before every other.
|
||||
var appended = await fx.Service.Ingest.CommitAsync(Request(fx, late), fx.Ct);
|
||||
var halfway = ProjectSettings.FromJson((await fx.Db.Sequences.GetAsync(sequenceId))!.SettingsJson!);
|
||||
Assert.Equal(3, halfway.HeroFrame);
|
||||
Assert.Count(1, halfway.PendingFrames!);
|
||||
Assert.Equal(early.Sha256, halfway.PendingFrames![0].Sha256);
|
||||
var inserted = await fx.Service.Ingest.CommitAsync(Request(fx, early), fx.Ct);
|
||||
|
||||
var row = (await fx.Db.Sequences.GetAsync(sequenceId))!;
|
||||
var frames = await fx.Db.Frames.ListBySequenceAsync(sequenceId);
|
||||
var placed = ProjectSettings.FromJson(row.SettingsJson!);
|
||||
Assert.SequenceEqual([inserted.FrameId, results[1].FrameId], placed.ExcludedFrames.Select(i => frames[i].Id));
|
||||
Assert.Equal(appended.FrameId, frames[placed.HeroFrame!.Value].Id);
|
||||
Assert.SequenceEqual([results[0].FrameId, appended.FrameId], placed.Camera.Keyframes.Select(k => frames[k.Frame].Id));
|
||||
Assert.Equal(0.3, placed.Camera.Keyframes[1].CenterX);
|
||||
Assert.Null(placed.PendingFrames);
|
||||
Assert.Equal(appended.FrameId, row.HeroFrameId);
|
||||
Assert.Equal(version, row.SettingsVersion);
|
||||
Assert.True(JsonNode.DeepEquals(JsonNode.Parse(row.SettingsJson!), JsonNode.Parse(File.ReadAllText(folder.ProjectPath))), "project.json mirrors the index");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task PhotosAFolderScanFindsMoveTheProjectPositionsButUnknownMembersStay()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user