fix(copies): address the owner review 6 findings
The review of the found-copies work showed pairs that could stick, jobs that could act on a pair the user had answered otherwise, and detection gaps: - forgetting a link on an address-keyed server deletes the pair and Candidate rows of that remote and resets the probe, so the sequence is found again when it is back; a Linked/Integrated row with no link is asked again - 404s count only on id-keyed servers, at most once per recheck interval - probes store the server's newest update time (copy_probes.server_newest, migration 0012) instead of comparing with this PC's clock; the lookup sample carries hashed photos by size and capture time too, for servers that have not hashed their copy - the older-server gate no longer re-compares unchanged manifests - a failed Integrate keeps its job id so a retry resumes only an untouched pair; cancel and stale plans release the pair (ReleaseAsync) - automatic photo transfers never create or retarget a sequence - a first upload files photos the server holds elsewhere into the new sequence - Unlink re-compares before keeping apart; Trash here names only true last copies; Drop... trashes one version on both sides after re-checking the other - a merge keeping the pair's other sequence swaps the dialog's columns and re-keys Different choices; Upload all reads every pair Each fix has a regression test where it makes sense. Refs #73 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
96b5b4078b
commit
fe752a0a21
33 files changed
+957
-123
No files matched your search
@@ -75,7 +75,7 @@ public sealed class SyncService
|
||||
private const int SweepLinks = 5;
|
||||
|
||||
/// <summary>How long a pair marked gone once waits before its remote is asked for again (design §6.3).</summary>
|
||||
private static readonly TimeSpan GoneRecheck = TimeSpan.FromMinutes(10);
|
||||
private static readonly TimeSpan GoneRecheck = FoundCopyStore.GoneRecheck;
|
||||
|
||||
/// <summary>Recomputes states without sending or taking settings on the user's behalf.</summary>
|
||||
internal static readonly SyncPolicy CompareOnly = new(AutoSyncSettings: false);
|
||||
@@ -390,6 +390,21 @@ public sealed class SyncService
|
||||
public Task<Job> EnqueueUploadAsync(JobEngine engine, string server, Sequence local, JobPriority priority, CancellationToken cancellationToken = default) =>
|
||||
EnqueueAsync(engine, JobKind.UploadCommit, local.Id, local.DisplayTitle, new SyncJobParameters(server), priority, cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Queues, in the background, the new photos of a pair integrated with automatic photos to its server sequence (owner
|
||||
/// review 6, design §7.3): the job sends only into the sequence the pair names, and fails rather than create another
|
||||
/// when that one is gone or the pair changed.
|
||||
/// </summary>
|
||||
internal Task<Job> EnqueueAutomaticUploadAsync(JobEngine engine, string server, Sequence local, CancellationToken cancellationToken = default) =>
|
||||
EnqueueAsync(engine, JobKind.UploadCommit, local.Id, local.DisplayTitle, new SyncJobParameters(server, Automatic: true), JobPriority.Background,
|
||||
cancellationToken);
|
||||
|
||||
/// <summary>The other way of <see cref="EnqueueAutomaticUploadAsync"/>: the server's new photos into the pair's local sequence only.</summary>
|
||||
internal Task<Job> EnqueueAutomaticDownloadAsync(JobEngine engine, string server, Guid remoteId, string title, Guid archiveId,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
EnqueueAsync(engine, JobKind.Download, remoteId, title, new SyncJobParameters(server, SyncDownloadMode.Originals, archiveId, Automatic: true),
|
||||
JobPriority.Background, cancellationToken);
|
||||
|
||||
/// <summary>Queues sending the renders of a local copy the server lacks (BRIEF §14.5), unless that is already waiting or running.</summary>
|
||||
public Task<Job> EnqueueSendExportsAsync(JobEngine engine, string server, Sequence local, CancellationToken cancellationToken = default) =>
|
||||
EnqueueAsync(engine, JobKind.UploadCommit, local.Id, local.DisplayTitle, new SyncJobParameters(server, Upload: SyncUploadMode.Exports), JobPriority.User,
|
||||
@@ -879,8 +894,9 @@ public sealed class SyncService
|
||||
|
||||
/// <summary>
|
||||
/// Keeps the deletion counts of a linked pair current at each comparison of its originals (design §6.2): photos one side
|
||||
/// deleted that the other still holds. A pair scored never before (a plain link an upload or download made) gets the
|
||||
/// whole detection score once, so a Keep apart after an Unlink is measured against what the two held when it was answered.
|
||||
/// deleted that the other still holds. A pair scored never before (a plain link an upload or download made), or whose
|
||||
/// photos moved on either side since its score, gets the whole detection score again, so a Keep apart after an Unlink is
|
||||
/// measured against what the two hold when it is answered.
|
||||
/// </summary>
|
||||
private async Task ScoreLinkedAsync(SyncLink link, Sequence local, SequenceManifest manifest, IReadOnlyDictionary<Guid, DateTime?>? captured,
|
||||
IReadOnlyCollection<FramePhoto> here, IReadOnlyCollection<FramePhoto> there, SyncTombstones tombstones, CancellationToken cancellationToken)
|
||||
@@ -888,7 +904,8 @@ public sealed class SyncService
|
||||
if (await Copies.FindRemoteAsync(local.Id, link.Server, link.RemoteId, cancellationToken).ConfigureAwait(false)
|
||||
is not { State: CopyState.Linked or CopyState.Integrated } row) return;
|
||||
CopyScore score;
|
||||
if (row.Score.LocalPhotos == 0 && row.Score.OtherPhotos == 0)
|
||||
if ((row.Score.LocalPhotos == 0 && row.Score.OtherPhotos == 0)
|
||||
|| row.LocalFramesVersion != local.FramesVersion || row.OtherFramesVersion != manifest.FramesVersion)
|
||||
{
|
||||
var side = await new CopySides(_db).LocalAsync(local.Id, cancellationToken).ConfigureAwait(false);
|
||||
score = CopyFinder.Detection(CopyComparer.Compare(side, CopyFinder.ServerSide(manifest, captured)).Score) with { Hints = row.Score.Hints };
|
||||
@@ -1178,12 +1195,16 @@ public sealed class SyncService
|
||||
|
||||
/// <summary>
|
||||
/// Forgets a link the server answered 404 for. With <paramref name="refreshId"/>, on a server keyed by its id (an address
|
||||
/// key may name another server tomorrow), the pair counts the 404 first (<see cref="FoundCopyStore.MarkRemoteGoneAsync"/>).
|
||||
/// key may name another server tomorrow), the pair counts the 404 first (<see cref="FoundCopyStore.MarkRemoteGoneAsync"/>);
|
||||
/// otherwise the pairs the link joined are settled (<see cref="FoundCopyStore.SettleForgottenAsync"/>), never left Linked
|
||||
/// with no link behind them.
|
||||
/// </summary>
|
||||
private async Task ForgetAsync(SyncLink link, Guid? refreshId, CancellationToken cancellationToken)
|
||||
{
|
||||
if (refreshId is { } id && ServerIdentity.IsIdKey(link.Server))
|
||||
await Copies.MarkRemoteGoneAsync(link.Server, link.RemoteId, link.LocalId, id, DateTimeOffset.UtcNow, cancellationToken).ConfigureAwait(false);
|
||||
else if (link.LocalId is { } localId)
|
||||
await Copies.SettleForgottenAsync(link.Server, link.RemoteId, localId, cancellationToken).ConfigureAwait(false);
|
||||
await _links.DeleteAsync(link.Server, link.RemoteId, cancellationToken).ConfigureAwait(false);
|
||||
Proxies.Delete(link.Server, link.RemoteId);
|
||||
Log.Info(LogCategory, $"{link.Title} is no longer on {link.Server}");
|
||||
@@ -1277,7 +1298,9 @@ public sealed class SyncService
|
||||
{
|
||||
var running = TransferKind(job);
|
||||
var outranked = running == SyncTransferKind.DownloadProxies && job.Priority < priority;
|
||||
if (running == wanted && !outranked) return job;
|
||||
// An automatic transfer never creates a sequence: it does not stand for the user's own.
|
||||
var narrower = SyncJobParameters.Read(job)?.IsAutomatic == true && !parameters.IsAutomatic;
|
||||
if (running == wanted && !outranked && !narrower) return job;
|
||||
if (outranked && wanted is SyncTransferKind.DownloadProxies or SyncTransferKind.DownloadOriginals)
|
||||
await engine.CancelAsync(job.Id, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user