Owner review 6 asks Chronos to recognise the same time-lapse held under different ids on the server and on this PC, compare the copies, and keep them apart or integrate and sync them. This lays the shared foundation the later parcels build on, without any UI or detection yet. - Migration 0012 adds found_copies (local-server and local-local pairs with evidence, scores, answer, policy and the 404 record) and copy_probes; every existing link with a local sequence becomes a Linked pair, so a server deletion and the per-link policy have a place. - FoundCopyStore keeps the pairs: upserts that never touch the answer, a compare-and-set of the state with an Integrating backstop (a failed or cancelled job reads as the previous state), link promotion and demotion, the once-per-refresh 404 count, the merge's links stage (session keys, links reset, pairs moved, refused when both are linked on one server), the local overlap queries and the probes. SyncLinkStore.RekeyAsync moves pairs and probes with the links in the same transaction. - Contracts for detection, review, plans, the Integrate and MergeSequences jobs (kinds 25/26, High level, new detail steps) and the Upload all rule that keeps suspected, kept-apart, deleted, busy and server-born sequences here. - Wire: POST photos/lookup, uploads into a target (IntoTarget/Copied, trailing and optional), frames/delete on the client, capabilities photo-lookup and upload-into, cached per remote. - The trash plans and deletes accept the job that holds the sequence (its own hold is not Busy) and a frames version checked under the lease; a Background job never interrupts a running one. - Settings for linking, the photo policy and projects; the en and it keys of design section 9. Refs #73 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
42 lines
2.4 KiB
C#
42 lines
2.4 KiB
C#
using Chronos.Data.Copies;
|
|
using Chronos.Testing;
|
|
|
|
namespace Chronos.Data.Tests.Copies;
|
|
|
|
/// <summary>The parameters of the Integrate and MergeSequences jobs (owner review 6, #73) survive the job row, and junk reads as none.</summary>
|
|
[Category("jobs")]
|
|
public sealed class CopyJobParametersTests
|
|
{
|
|
[Test]
|
|
public void IntegrateParametersRoundTrip()
|
|
{
|
|
var choices = new IntegrateChoices(CopyPhotoPolicy.ChoosePerPhoto, new Dictionary<string, PhotoChoice> { ["h:ab"] = PhotoChoice.KeepBoth },
|
|
new Dictionary<string, CopySide> { ["title"] = CopySide.Other }, CopyProjects.Leave);
|
|
var parameters = new IntegrateJobParameters(Guid.NewGuid(), "https://nas.test:8443", Guid.CreateVersion7(), Guid.CreateVersion7(), choices, "fp", true);
|
|
var json = parameters.ToJson();
|
|
// Enums are written by name: a value appended later never shifts what a queued job meant.
|
|
Assert.Contains("\"ChoosePerPhoto\"", json);
|
|
Assert.Contains("\"autoPhotos\":true", json);
|
|
var back = IntegrateJobParameters.Read(json)!;
|
|
Assert.Equal((parameters.CopyId, parameters.Server, parameters.LocalId, parameters.RemoteId, "fp", true),
|
|
(back.CopyId, back.Server, back.LocalId, back.RemoteId, back.Fingerprint, back.AutoPhotos));
|
|
Assert.Equal((CopyPhotoPolicy.ChoosePerPhoto, PhotoChoice.KeepBoth, CopySide.Other, CopyProjects.Leave),
|
|
(back.Choices.Photos, back.Choices.PerPhoto["h:ab"], back.Choices.Details["title"], back.Choices.Projects));
|
|
Assert.Null(IntegrateJobParameters.Read(null));
|
|
Assert.Null(IntegrateJobParameters.Read("{not json"));
|
|
Assert.Null(IntegrateJobParameters.Read("{}"));
|
|
}
|
|
|
|
[Test]
|
|
public void MergeParametersRoundTrip()
|
|
{
|
|
var choices = new MergeChoices(CopyPhotoPolicy.Union, new Dictionary<string, PhotoChoice>(), new Dictionary<string, CopySide>());
|
|
var parameters = new MergeJobParameters(Guid.NewGuid(), Guid.CreateVersion7(), Guid.CreateVersion7(), choices, "fp");
|
|
var back = MergeJobParameters.Read(parameters.ToJson())!;
|
|
Assert.Equal((parameters.CopyId, parameters.KeepId, parameters.DropId, "fp", CopyPhotoPolicy.Union),
|
|
(back.CopyId, back.KeepId, back.DropId, back.Fingerprint, back.Choices.Photos));
|
|
Assert.Null(MergeJobParameters.Read(" "));
|
|
Assert.Null(MergeJobParameters.Read("[1]"));
|
|
}
|
|
}
|