fix(sync): record scan stamps after a pulled title only when the index held the folder

ApplyLocallyAsync recorded the folder's scan stamps unconditionally after
writing the server's title, tags, rating or notes into the sidecar. Photos
another process (a desktop sharing this archive) had listed there since
this index last synced the folder then stayed out of the index until the
folder changed again, and the row's frames version stayed behind the
sidecar's, so analyses here recorded nothing for the sequence meanwhile.

It now asks ArchiveIndexer.InStepAsync before its sidecar write, as the
other partial writers do, and records the stamps only when that held.

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 22:08:36 +00:00
1 parent 79125b547a
commit 8927ac97e2
2 files changed
+34 -1

No files matched your search

+4 -1
View File
@@ -767,6 +767,9 @@ public sealed class SyncService
if (metadata)
{
var manifest = SequenceWriter.ReadLocked(folder, row.Id);
// Asked before the sidecar is written: frames or flags another process wrote there since this index last
// synced the folder keep it changed for the next scan (ArchiveIndexer.InStepAsync).
var inStep = await Archives.Indexer.InStepAsync(archive, folder, manifest, cancellationToken).ConfigureAwait(false);
ManifestStore.WriteSequence(folder.ManifestPath, manifest with
{
Title = updated.Title,
@@ -776,7 +779,7 @@ public sealed class SyncService
Versions = manifest.Versions with { Settings = Math.Max(manifest.Versions.Settings, updated.SettingsVersion) },
UpdatedAt = DateTimeOffset.UtcNow,
});
await Archives.Indexer.RecordStampsAsync(archive, folder, row.Id, cancellationToken).ConfigureAwait(false);
if (inStep) await Archives.Indexer.RecordStampsAsync(archive, folder, row.Id, cancellationToken).ConfigureAwait(false);
}
return updated;
}
@@ -1,6 +1,8 @@
using Titano.Core.Model;
using Titano.Core.Project;
using Titano.Data.Archiving;
using Titano.Data.Sync;
using Titano.Data.Tests.Archiving;
using Titano.Protocol;
using Titano.Protocol.Client;
using Titano.Testing;
@@ -289,6 +291,34 @@ public sealed class SyncServiceTests(TestContext context)
Assert.SequenceEqual(["sunset"], (await f.Db.Sequences.GetAsync(local.Id, f.Ct))!.Tags);
}
[Test]
public async Task InfoTakenFromTheServerLeavesPhotosAnotherWriterAddedHereToTheNextScan()
{
await using var f = await SyncFixture.CreateAsync(context);
var photos = f.NewPhotos(2);
var local = await f.LocalAsync("Harbour", photos);
var remote = f.Remote.Add("Harbour", photos);
await f.Sync.LinkAsync(f.Server, remote.Id, local.Id, f.Ct);
await f.RefreshAsync();
// A desktop sharing this PC's archive imports a photo into the sequence: its own index follows the sidecar, this one not yet.
var (desktop, archive) = await f.Archive.OtherWriterAsync();
var staged = f.Archive.Stage(ArchiveFixture.Start.AddMinutes(10), seed: 90);
await desktop.Ingest.CommitAsync(new IngestRequest(archive.Id, local.Id, null, null, staged.Path, "IMG_0009.JPG", staged.Size, staged.Sha256, null, null),
f.Ct);
// The server's new title reaches this PC meanwhile, in its index and the sidecar.
await f.Remote.UpdateSequenceAsync(remote.Id, new UpdateSequenceRequest("Harbour at dusk", null, null, null, null, null), f.Ct);
await f.RefreshAsync();
var taken = (await f.Db.Sequences.GetAsync(local.Id, f.Ct))!;
Assert.Equal(("Harbour at dusk", 2), (taken.Title, taken.FrameCount));
// The next scan still finds the folder changed, and indexes the photo.
Assert.Contains(local.Id, (await f.Archive.ScanAsync()).Sequences);
var row = (await f.Db.Sequences.GetAsync(local.Id, f.Ct))!;
Assert.Equal(("Harbour at dusk", 3), (row.Title, row.FrameCount));
}
[Test]
public async Task TheSameEditOnBothSidesIsAgreedWithoutAConflict()
{