fix(copies): close the owner review 6 second verification findings
Upload again now deletes the gone pair row once the new sequence is linked, so the pair stops reading "deleted on server" or "kept here". A linked upload the server refuses into its sequence (403 for an account without Edit that does not own it) falls back to ordinary uploads instead of failing; an Integrate that would add photos to such a sequence is blocked in its plan (NoAddRight). Automatic photo transfers pause on a metered connection whatever the option says. Integrate trashes server photos only against the manifest version that checked the winner, and a merge is blocked while the other sequence holds a damaged photo nothing else holds (DamagedPhotos), so nothing unverified reaches the trash. The plan and the confirmations now say what really happens: replaced versions are no longer counted as kept, a merge lists the kept sequence's replaced photos, plan lines use the text colour, an integrated pair that left photos out says new photos move by hand, and a merging pair reads "merging" with its progress. The Compare dialog gets per-side tooltips, class sizes for both sides, policy-aware class tooltips, column headings and readable file names; the sync table shows "deleted there" with Review and warns on skipped rows; the Edit picker names the server, the Library card shows the match status second, a deleted server sequence is named instead of "0 photos", and the match tooltips stop calling a sequence a copy. The capture scenes use the server name, the link names and consistent sample sizes. Refs #73 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b34b6b6fe0
commit
9657c1711d
44 files changed
+802
-128
No files matched your search
@@ -405,6 +405,17 @@ public sealed class SyncService
|
||||
EnqueueAsync(engine, JobKind.Download, remoteId, title, new SyncJobParameters(server, SyncDownloadMode.Originals, archiveId, Automatic: true),
|
||||
JobPriority.Background, cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Whether <paramref name="job"/> is an automatic transfer of an integrated pair's new photos
|
||||
/// (<see cref="EnqueueAutomaticUploadAsync"/>, <see cref="EnqueueAutomaticDownloadAsync"/>): a metered connection pauses
|
||||
/// those whatever the option says (owner review 6, Q6).
|
||||
/// </summary>
|
||||
public static bool IsAutomaticTransfer(Job job)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(job);
|
||||
return SyncJobParameters.Read(job)?.IsAutomatic == true;
|
||||
}
|
||||
|
||||
/// <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,
|
||||
|
||||
@@ -98,12 +98,15 @@ internal sealed class SyncTransfers(SyncService sync)
|
||||
|
||||
// A server that files a photo it holds in another sequence into this one (owner review 6): the map's "missing on the
|
||||
// server" reaches 0 once every original is in the target, not merely somewhere on the server.
|
||||
var into = (await remote.CapabilitiesAsync(ct).ConfigureAwait(false)).Contains(ServerCapabilities.UploadInto);
|
||||
if (into)
|
||||
// An account that may upload but neither owns the target nor may edit it is refused that (403): the originals then go
|
||||
// as before, each to the target unless the server holds it elsewhere (IntoRefusal).
|
||||
var into = (await remote.CapabilitiesAsync(ct).ConfigureAwait(false)).Contains(ServerCapabilities.UploadInto) ? new IntoRefusal() : null;
|
||||
if (into is not null)
|
||||
{
|
||||
// Counted already (they reached the server before the target existed): filed into it now, nothing stepped again.
|
||||
foreach (var frame in heldElsewhere)
|
||||
{
|
||||
if (into.Refused) break;
|
||||
if (await UploadFrameAsync(context, remote, target, null, paths.FromRelative(frame.RelativePath), frame, tombstones, hashes, ct, into)
|
||||
.ConfigureAwait(false) is null)
|
||||
skipped++;
|
||||
@@ -978,8 +981,18 @@ internal sealed class SyncTransfers(SyncService sync)
|
||||
/// original the index has none for goes into <paramref name="hashes"/>; known by content only now, such an original
|
||||
/// the server deleted (<paramref name="tombstones"/>) is not sent back.
|
||||
/// </summary>
|
||||
private static Task<CompleteUploadResponse?> UploadFrameAsync(JobContext context, ISyncRemote remote, Guid? sequenceId, string? sessionKey, string path,
|
||||
Frame frame, SyncTombstones tombstones, ConcurrentDictionary<Guid, string> hashes, CancellationToken cancellationToken, IntoRefusal? into) =>
|
||||
UploadFrameAsync(context, remote, sequenceId, sessionKey, path, frame, tombstones, hashes, cancellationToken, into is not null, into);
|
||||
|
||||
/// <summary>
|
||||
/// <paramref name="into"/>: through <see cref="ISyncRemote.UploadFileIntoAsync"/>; with <paramref name="fallback"/>, a
|
||||
/// 403 for that (an account that neither owns the target nor may edit it) sends this original and every later one of
|
||||
/// the job the plain way instead (<see cref="IntoRefusal"/>).
|
||||
/// </summary>
|
||||
private static async Task<CompleteUploadResponse?> UploadFrameAsync(JobContext context, ISyncRemote remote, Guid? sequenceId, string? sessionKey, string path,
|
||||
Frame frame, SyncTombstones tombstones, ConcurrentDictionary<Guid, string> hashes, CancellationToken cancellationToken, bool into = false)
|
||||
Frame frame, SyncTombstones tombstones, ConcurrentDictionary<Guid, string> hashes, CancellationToken cancellationToken, bool into = false,
|
||||
IntoRefusal? fallback = null)
|
||||
{
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
@@ -1002,11 +1015,35 @@ internal sealed class SyncTransfers(SyncService sync)
|
||||
context.Log(Loc.L("Archive.Log.SyncChanged", frame.FileName));
|
||||
return null;
|
||||
}
|
||||
if (into && sequenceId is { } target)
|
||||
return await remote.UploadFileIntoAsync(path, target, sha, frame.CapturedAt, cancellationToken).ConfigureAwait(false) ?? notSent;
|
||||
if (into && sequenceId is { } target && fallback is not { Refused: true })
|
||||
{
|
||||
try
|
||||
{
|
||||
return await remote.UploadFileIntoAsync(path, target, sha, frame.CapturedAt, cancellationToken).ConfigureAwait(false) ?? notSent;
|
||||
}
|
||||
catch (ChronosApiException ex) when (fallback is not null && ex.Status == HttpStatusCode.Forbidden
|
||||
&& string.Equals(ex.Error.Code, "forbidden", StringComparison.Ordinal))
|
||||
{
|
||||
if (fallback.Refuse()) context.Log(Loc.L("Archive.Log.SyncIntoRefused"));
|
||||
}
|
||||
}
|
||||
return await remote.UploadFileAsync(path, sequenceId, sessionKey, sha, frame.CapturedAt, cancellationToken).ConfigureAwait(false) ?? notSent;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the server refused an upload into the target to this account (owner review 6, #73): set once, by the first
|
||||
/// refusal; the job's later originals go the plain way, as before the server could file into a target.
|
||||
/// </summary>
|
||||
private sealed class IntoRefusal
|
||||
{
|
||||
private int _refused;
|
||||
|
||||
public bool Refused => Volatile.Read(ref _refused) == 1;
|
||||
|
||||
/// <summary>Records the refusal; true for the first one.</summary>
|
||||
public bool Refuse() => Interlocked.Exchange(ref _refused, 1) == 0;
|
||||
}
|
||||
|
||||
/// <summary>Commits one original from staging into the local sequence (created from the server id when null).</summary>
|
||||
private async Task<IngestResult> CommitAsync(Guid remoteId, Guid archiveId, Guid? sequenceId, ManifestFrame frame, string staged, string sha,
|
||||
IReadOnlyDictionary<Guid, DateTime?> captured, CancellationToken cancellationToken)
|
||||
|
||||
Reference in new issue
Block a user