fix(sync): send wanted proxies of unverified originals and recount them
Wanted proxies were matched to this PC's originals by SHA-256 only, and frames adopted from a folder stay unhashed until verified. A desktop that uploaded an adopted HEIC folder counted none of the proxies the server asked for, showed the link in sync and sent none of them. The upload now keeps the hash it computes for each original the index has none for and makes the proxies from those too; the comparison counts a wanted frame no hash matched against an unhashed original this PC reads by size (the server names its copy by its own template, so not by name). The wanted count was recomputed only when frame or render counters moved, so proxies a render node sent left the row "Local ahead" with an upload that sent nothing, and proxies the server started asking for later were never counted. A link whose copy may make proxies for the server now keeps the server's update time of the last comparison (sync_links.diff_remote_updated_at, migration 0006) and is compared again when it moved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
9 files changed
+198
-18
No files matched your search
@@ -490,7 +490,8 @@ public sealed class SyncService
|
||||
}
|
||||
SequenceManifest? manifest = null;
|
||||
if (link.DiffLocalFrames != local.FramesVersion || link.DiffRemoteFrames != link.RemoteFramesVersion
|
||||
|| link.DiffLocalRenders != local.RenderedCount || link.DiffRemoteRenders != link.RenderCount)
|
||||
|| link.DiffLocalRenders != local.RenderedCount || link.DiffRemoteRenders != link.RenderCount
|
||||
|| (link.DiffRemoteUpdatedAt is { } compared && !SameMoment(compared, link.RemoteUpdatedAt)))
|
||||
{
|
||||
manifest = await remote.GetManifestAsync(link.RemoteId, cancellationToken).ConfigureAwait(false);
|
||||
var frames = await SequenceFrames.ListAsync(_db, local.Id, cancellationToken).ConfigureAwait(false);
|
||||
@@ -498,7 +499,10 @@ public sealed class SyncService
|
||||
var present = frames.Where(f => (f.Flags & FrameFlags.Missing) == 0).ToList();
|
||||
var (missingRemote, missingLocal) = SyncRules.CompareOriginals([.. present.Select(f => f.Sha256)], [.. manifest.Frames.Select(f => f.Sha256)]);
|
||||
// Proxies the server asks for that this PC can make from its originals travel with an upload too (BRIEF §2.3).
|
||||
if (policy.CanEdit && manifest.Proxies is not null) missingRemote += SyncRules.ProxiesToSend(manifest, present, Options.Archive.Decoder);
|
||||
var proxies = policy.CanEdit && manifest.Proxies is not null ? SyncRules.ProxiesToSend(manifest, present, Options.Archive.Decoder) : 0;
|
||||
// Those change without the server's frame counters moving: while some may be made here, the server's next
|
||||
// change of the sequence brings a new comparison.
|
||||
var watch = policy.CanEdit && (proxies > 0 || SyncRules.MakesProxiesFor(present, Options.Archive.Decoder));
|
||||
link = await CompareExportsAsync(link, local, manifest.Renders, cancellationToken).ConfigureAwait(false) with
|
||||
{
|
||||
DiffLocalFrames = local.FramesVersion,
|
||||
@@ -506,7 +510,8 @@ public sealed class SyncService
|
||||
RemoteFramesVersion = manifest.FramesVersion,
|
||||
DiffLocalRenders = local.RenderedCount,
|
||||
DiffRemoteRenders = manifest.Renders.Count,
|
||||
MissingRemote = missingRemote,
|
||||
DiffRemoteUpdatedAt = watch ? link.RemoteUpdatedAt : null,
|
||||
MissingRemote = missingRemote + proxies,
|
||||
MissingLocal = missingLocal,
|
||||
};
|
||||
}
|
||||
@@ -639,6 +644,9 @@ public sealed class SyncService
|
||||
|
||||
private static DateTime Second(DateTime time) => new(time.Ticks - time.Ticks % TimeSpan.TicksPerSecond, DateTimeKind.Unspecified);
|
||||
|
||||
/// <summary>The same instant as databases keep it (to the microsecond).</summary>
|
||||
private static bool SameMoment(DateTimeOffset a, DateTimeOffset b) => a.UtcTicks / 10 == b.UtcTicks / 10;
|
||||
|
||||
/// <summary>
|
||||
/// Writes a payload into the local index, project and sidecar in one step (settings version + 1) under the sequence's
|
||||
/// lease, which the editor's saves take too, and only while the local copy is still at the settings version
|
||||
@@ -871,6 +879,7 @@ public sealed class SyncService
|
||||
DiffRemoteFrames = null,
|
||||
DiffLocalRenders = null,
|
||||
DiffRemoteRenders = null,
|
||||
DiffRemoteUpdatedAt = null,
|
||||
MissingRemote = 0,
|
||||
MissingLocal = 0,
|
||||
ExportsToGet = 0,
|
||||
|
||||
Reference in new issue
Block a user