feat: found copies foundation (contracts, migration 0012, store, wire, trash and job hooks, keys)
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>
This commit is contained in:
1 parent
43719bb5c5
commit
283d04d9cd
57 files changed
+3302
-26
No files matched your search
@@ -99,3 +99,8 @@ dotnet run --project src/Chronos.Tools -- i18n check
|
||||
| Main | Name of every sequence's first project, holding the sequence's own settings | Principale |
|
||||
| Versions | The saved states of a project, listed in its history | Versioni |
|
||||
| Workspace copy | The job that copies a project's photos into the workspace | Copia di lavoro |
|
||||
| Match | Two copies of one time-lapse found here and on a server, or twice on this PC (owner review 6); never "duplicate" or "copy", which name the photo duplicates report | Corrispondenza (mai Doppione, Duplicato o Copia) |
|
||||
| Integrate | Complete two matched sequences with each other's photos, settle their differences once, then keep them in sync | Integra |
|
||||
| Merge sequences | Join two matched sequences of this PC into the kept one; the other goes to the trash after verification | Unisci sequenze |
|
||||
| Keep apart | Answer to a match: the two stay separate sequences and are not asked about again | Tieni separate |
|
||||
| Twin | A workspace project of the same time-lapse at the other home, marked in the Edit picker | Gemella |
|
||||
@@ -1247,4 +1247,9 @@
|
||||
<data name="Admin.Job.Speed.PerSecond" xml:space="preserve"><value>{0}/s</value></data>
|
||||
<data name="Admin.Job.Speed.Bytes" xml:space="preserve"><value>{0}/s</value></data>
|
||||
<data name="Admin.Job.Left" xml:space="preserve"><value>{0} left</value></data>
|
||||
<data name="Admin.Job.Kind.Integrate" xml:space="preserve"><value>Integrate sequences</value></data>
|
||||
<data name="Admin.Job.Kind.MergeSequences" xml:space="preserve"><value>Merge sequences</value></data>
|
||||
<data name="Admin.Job.Step.Details" xml:space="preserve"><value>Settling details</value></data>
|
||||
<data name="Admin.Job.Step.Projects" xml:space="preserve"><value>Copying projects</value></data>
|
||||
<data name="Admin.Job.Step.Trash" xml:space="preserve"><value>Moving to the trash</value></data>
|
||||
</root>
|
||||
@@ -454,4 +454,10 @@
|
||||
<data name="Archive.Log.WorkspaceSendNoProvenance" xml:space="preserve"><value>{0}: the server kept the render without its project; update the server to keep it</value><comment>long: job log line; {0} render file name</comment></data>
|
||||
<data name="Archive.Log.WorkspaceMoveLeft" xml:space="preserve"><value>Moved; {0} still holds {1} item(s) that could not be cleared</value><comment>long: job log line; {0} old folder; {1} a count</comment></data>
|
||||
<data name="Archive.Trash.Kind.Videos" xml:space="preserve"><value>Videos</value></data>
|
||||
<data name="Archive.Log.CopySent" xml:space="preserve"><value>{0}: sent into the linked sequence</value><comment>long: job log line</comment></data>
|
||||
<data name="Archive.Log.CopyFetched" xml:space="preserve"><value>{0}: received into this PC's sequence</value><comment>long: job log line</comment></data>
|
||||
<data name="Archive.Log.CopyReplaced" xml:space="preserve"><value>{0}: older version to the trash</value><comment>long: job log line</comment></data>
|
||||
<data name="Archive.Log.CopyProject" xml:space="preserve"><value>Project {0} copied as {1}</value><comment>long: job log line</comment></data>
|
||||
<data name="Archive.Log.MergeCopied" xml:space="preserve"><value>{0}: copied and verified</value><comment>long: job log line</comment></data>
|
||||
<data name="Archive.Log.MergeTrashed" xml:space="preserve"><value>{0} moved to the trash</value><comment>long: job log line</comment></data>
|
||||
</root>
|
||||
@@ -492,4 +492,5 @@
|
||||
<data name="Editor.RenderMenu.Videos" xml:space="preserve"><value>Videos</value></data>
|
||||
<data name="Editor.RenderMenu.Details" xml:space="preserve"><value>{0} · {1} · {2}</value><comment>invariant: a preset's size, codec and frame rate</comment></data>
|
||||
<data name="Editor.Still.Queued" xml:space="preserve"><value>Frame save queued</value></data>
|
||||
<data name="Editor.Picker.Twin" xml:space="preserve"><value>Twin</value></data>
|
||||
</root>
|
||||
@@ -133,4 +133,32 @@
|
||||
<data name="Errors.Videos.TrashMismatch" xml:space="preserve"><value>The trashed video no longer matches its record; it stays in the trash.</value></data>
|
||||
<data name="Errors.Videos.Busy" xml:space="preserve"><value>A job is using {0}; try again when it ends.</value><comment>{0} file name</comment></data>
|
||||
<data name="Errors.Videos.CannotPlay" xml:space="preserve"><value>Windows cannot decode this file here; Show in folder opens its folder.</value></data>
|
||||
<data name="Errors.Copies.StalePlan" xml:space="preserve"><value>The sequences changed since the plan: compare them again.</value></data>
|
||||
<data name="Errors.Copies.LinkTaken" xml:space="preserve"><value>{0} is already linked to another sequence of {1}.</value></data>
|
||||
<data name="Errors.Copies.DetailsChanged" xml:space="preserve"><value>The details changed on one side meanwhile; the photos are in place, compare again.</value></data>
|
||||
<data name="Errors.Copies.Changed" xml:space="preserve"><value>{0} changed while it was being merged; nothing went to the trash.</value></data>
|
||||
<data name="Errors.Copies.ChangedFile" xml:space="preserve"><value>{0} no longer matches its recorded hash; nothing went to the trash. Run Verify.</value></data>
|
||||
<data name="Errors.Copies.RemoteGone" xml:space="preserve"><value>The server deleted its sequence meanwhile; nothing more was sent.</value></data>
|
||||
<data name="Errors.Copies.VerifyFailed.one" xml:space="preserve"><value>{0} photo did not match after copying: nothing went to the trash.</value></data>
|
||||
<data name="Errors.Copies.VerifyFailed.other" xml:space="preserve"><value>{0} photos did not match after copying: nothing went to the trash.</value></data>
|
||||
<data name="Errors.Copies.Kept.one" xml:space="preserve"><value>{0} photo stayed as it was; the job log says why.</value></data>
|
||||
<data name="Errors.Copies.Kept.other" xml:space="preserve"><value>{0} photos stayed as they were; the job log says why.</value></data>
|
||||
<data name="Errors.Copies.ProjectsKept.one" xml:space="preserve"><value>{0} project was not copied; the job log says why.</value></data>
|
||||
<data name="Errors.Copies.ProjectsKept.other" xml:space="preserve"><value>{0} projects were not copied; the job log says why.</value></data>
|
||||
<data name="Errors.Copies.NoSpace" xml:space="preserve"><value>{0} needs {1} free; free some space and try again.</value></data>
|
||||
<data name="Errors.Copies.Busy" xml:space="preserve"><value>A job is working on one of these sequences; try again when it ends.</value></data>
|
||||
<data name="Errors.Copies.Unsent" xml:space="preserve"><value>Send or discard the workspace changes of {0} first.</value></data>
|
||||
<data name="Errors.Copies.BothLinked" xml:space="preserve"><value>Both sequences are linked to {0}: integrate them there first.</value></data>
|
||||
<data name="Errors.Copies.TrashBlocked" xml:space="preserve"><value>{0} cannot go to the trash: {1}</value></data>
|
||||
<data name="Errors.Copies.DetailsUnchosen.one" xml:space="preserve"><value>Choose {0} detail first.</value></data>
|
||||
<data name="Errors.Copies.DetailsUnchosen.other" xml:space="preserve"><value>Choose {0} details first.</value></data>
|
||||
<data name="Errors.Copies.KeptUnchosen" xml:space="preserve"><value>Choose the sequence to keep.</value></data>
|
||||
<data name="Errors.Copies.NeedsNewerServer" xml:space="preserve"><value>{0} needs an update to integrate sequences.</value></data>
|
||||
<data name="Errors.Copies.NoUploadRight" xml:space="preserve"><value>The server account may not upload photos.</value></data>
|
||||
<data name="Errors.Copies.NoFetchRight" xml:space="preserve"><value>The server account may not download originals.</value></data>
|
||||
<data name="Errors.Copies.NoEditRight" xml:space="preserve"><value>The server account may not change the details.</value></data>
|
||||
<data name="Errors.Copies.NoDeleteRight" xml:space="preserve"><value>The server account may not delete these photos.</value></data>
|
||||
<data name="Errors.Copies.ArchiveOffline" xml:space="preserve"><value>The archive of {0} is offline; connect it and try again.</value></data>
|
||||
<data name="Errors.Copies.FolderMoved" xml:space="preserve"><value>{0} is not where the index has it; try again after the next scan.</value></data>
|
||||
<data name="Errors.Copies.NotThere" xml:space="preserve"><value>The other side no longer deleted these photos; nothing went to the trash.</value></data>
|
||||
</root>
|
||||
@@ -256,4 +256,11 @@
|
||||
<data name="Jobs.Part.Step" xml:space="preserve"><value>step {0} of {1}</value></data>
|
||||
<data name="Jobs.Detail.Count" xml:space="preserve"><value>{0} of {1}</value></data>
|
||||
<data name="Jobs.Detail.StoppedAt" xml:space="preserve"><value>Stopped at {0}</value></data>
|
||||
<data name="Jobs.Kind.Integrate" xml:space="preserve"><value>Integrate sequences</value></data>
|
||||
<data name="Jobs.Kind.MergeSequences" xml:space="preserve"><value>Merge sequences</value></data>
|
||||
<data name="Jobs.Target.Integrate" xml:space="preserve"><value>Integrate {0}</value></data>
|
||||
<data name="Jobs.Target.Merge" xml:space="preserve"><value>Merge into {0}</value></data>
|
||||
<data name="Jobs.Step.Details" xml:space="preserve"><value>Settling details</value></data>
|
||||
<data name="Jobs.Step.Projects" xml:space="preserve"><value>Copying projects</value></data>
|
||||
<data name="Jobs.Step.Trash" xml:space="preserve"><value>Moving to the trash</value></data>
|
||||
</root>
|
||||
@@ -125,4 +125,7 @@
|
||||
<data name="Library.Views.SaveMenu" xml:space="preserve"><value>Save view…</value></data>
|
||||
<data name="Library.Views.Saved" xml:space="preserve"><value>View {0} saved</value><comment>long</comment></data>
|
||||
<data name="Library.Views.Undo" xml:space="preserve"><value>Undo</value></data>
|
||||
<data name="Library.Status.CopyFound" xml:space="preserve"><value>Also elsewhere</value></data>
|
||||
<data name="Library.Status.DeletedThere" xml:space="preserve"><value>Deleted there</value></data>
|
||||
<data name="Library.Action.Compare" xml:space="preserve"><value>Compare…</value></data>
|
||||
</root>
|
||||
@@ -295,4 +295,158 @@
|
||||
<data name="Server.Error.TrashHashMismatch" xml:space="preserve"><value>The trashed video no longer matches its record; it stays in the trash.</value><comment>long</comment></data>
|
||||
<data name="Server.Error.SequenceGone" xml:space="preserve"><value>The video's sequence is not in the library: restore the sequence first.</value><comment>long</comment></data>
|
||||
<data name="Server.Error.VideoBusy" xml:space="preserve"><value>A job is using this video; try again when it ends.</value><comment>long</comment></data>
|
||||
<data name="Server.Sync.Filter.FoundCopies" xml:space="preserve"><value>Matches · {0}</value></data>
|
||||
<data name="Server.Sync.QueuedSkipped" xml:space="preserve"><value>Queued: {0} · skipped: {1}</value></data>
|
||||
<data name="Server.Sync.Show" xml:space="preserve"><value>Show</value></data>
|
||||
<data name="Server.Sync.State.CopyFound" xml:space="preserve"><value>match found</value></data>
|
||||
<data name="Server.Sync.State.RemoteGone" xml:space="preserve"><value>deleted on server</value></data>
|
||||
<data name="Server.Sync.State.KeptHere" xml:space="preserve"><value>kept here</value></data>
|
||||
<data name="Server.Sync.State.Skipped" xml:space="preserve"><value>skipped</value></data>
|
||||
<data name="Server.Sync.State.NotSent" xml:space="preserve"><value>not sent</value></data>
|
||||
<data name="Server.Sync.NotSentToast" xml:space="preserve"><value>{0}: photos not sent</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Column.Sequence" xml:space="preserve"><value>Sequence</value></data>
|
||||
<data name="Server.Copies.Column.ThisSide" xml:space="preserve"><value>This side</value></data>
|
||||
<data name="Server.Copies.Column.OtherSide" xml:space="preserve"><value>Other side</value></data>
|
||||
<data name="Server.Copies.Column.State" xml:space="preserve"><value>State</value></data>
|
||||
<data name="Server.Copies.State.Candidate" xml:space="preserve"><value>match found</value></data>
|
||||
<data name="Server.Copies.State.KeptApart" xml:space="preserve"><value>kept apart</value></data>
|
||||
<data name="Server.Copies.State.Linked" xml:space="preserve"><value>linked</value></data>
|
||||
<data name="Server.Copies.State.Integrating" xml:space="preserve"><value>integrating · {0} of {1}</value></data>
|
||||
<data name="Server.Copies.State.Integrated" xml:space="preserve"><value>integrated</value></data>
|
||||
<data name="Server.Copies.State.RemoteGone" xml:space="preserve"><value>deleted on server</value></data>
|
||||
<data name="Server.Copies.State.KeptHere" xml:space="preserve"><value>kept here</value></data>
|
||||
<data name="Server.Copies.State.DeletedThere" xml:space="preserve"><value>deleted there · {0}</value></data>
|
||||
<data name="Server.Copies.State.DeletedOther" xml:space="preserve"><value>deleted in the other · {0}</value></data>
|
||||
<data name="Server.Copies.Action.Compare" xml:space="preserve"><value>Compare…</value></data>
|
||||
<data name="Server.Copies.Action.Integrate" xml:space="preserve"><value>Integrate…</value></data>
|
||||
<data name="Server.Copies.Action.MergeRow" xml:space="preserve"><value>Merge…</value></data>
|
||||
<data name="Server.Copies.Action.IntegrateNow" xml:space="preserve"><value>Integrate</value></data>
|
||||
<data name="Server.Copies.Action.Merge" xml:space="preserve"><value>Merge</value></data>
|
||||
<data name="Server.Copies.Action.KeepApart" xml:space="preserve"><value>Keep apart</value></data>
|
||||
<data name="Server.Copies.Action.LinkOnly" xml:space="preserve"><value>Link only</value></data>
|
||||
<data name="Server.Copies.Action.Unlink" xml:space="preserve"><value>Unlink</value></data>
|
||||
<data name="Server.Copies.Action.Undo" xml:space="preserve"><value>Undo</value></data>
|
||||
<data name="Server.Copies.Action.AskAgain" xml:space="preserve"><value>Ask again</value></data>
|
||||
<data name="Server.Copies.Action.Find" xml:space="preserve"><value>Find matches</value></data>
|
||||
<data name="Server.Copies.Action.UploadAgain" xml:space="preserve"><value>Upload again</value></data>
|
||||
<data name="Server.Copies.Action.KeepHere" xml:space="preserve"><value>Keep here</value></data>
|
||||
<data name="Server.Copies.Action.ToTrash" xml:space="preserve"><value>To trash…</value></data>
|
||||
<data name="Server.Copies.Action.DeleteOnServer" xml:space="preserve"><value>Delete on server…</value></data>
|
||||
<data name="Server.Copies.Action.Review" xml:space="preserve"><value>Review</value></data>
|
||||
<data name="Server.Copies.Action.Drop" xml:space="preserve"><value>Drop…</value></data>
|
||||
<data name="Server.Copies.Action.Choose" xml:space="preserve"><value>Choose</value></data>
|
||||
<data name="Server.Copies.Empty" xml:space="preserve"><value>No matches found.</value></data>
|
||||
<data name="Server.Copies.ControlFor" xml:space="preserve"><value>{0}: {1}</value></data>
|
||||
<data name="Server.Copies.Where.ThisPc" xml:space="preserve"><value>This PC · {0}</value></data>
|
||||
<data name="Server.Copies.Where.Archive.one" xml:space="preserve"><value>{1} · {0} photo</value></data>
|
||||
<data name="Server.Copies.Where.Archive.other" xml:space="preserve"><value>{1} · {0} photos</value></data>
|
||||
<data name="Server.Copies.Where.Server.one" xml:space="preserve"><value>{1} · {0} photo</value></data>
|
||||
<data name="Server.Copies.Where.Server.other" xml:space="preserve"><value>{1} · {0} photos</value></data>
|
||||
<data name="Server.Copies.Facts.one" xml:space="preserve"><value>{1} · {0} photo · {2}</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Facts.other" xml:space="preserve"><value>{1} · {0} photos · {2}</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Found.one" xml:space="preserve"><value>{0} match found</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Found.other" xml:space="preserve"><value>{0} matches found</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Linked.one" xml:space="preserve"><value>{0} sequence linked</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Linked.other" xml:space="preserve"><value>{0} sequences linked</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Unlinked" xml:space="preserve"><value>Unlinked {0}</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.KeptApartToast" xml:space="preserve"><value>Kept apart: {0}</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.DeletedToast.one" xml:space="preserve"><value>{0} photo deleted on {1}</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.DeletedToast.other" xml:space="preserve"><value>{0} photos deleted on {1}</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Dialog.Compare" xml:space="preserve"><value>Compare sequences</value></data>
|
||||
<data name="Server.Copies.Dialog.Merge" xml:space="preserve"><value>Merge sequences</value></data>
|
||||
<data name="Server.Copies.Part.Photos" xml:space="preserve"><value>Photos</value></data>
|
||||
<data name="Server.Copies.Part.Details" xml:space="preserve"><value>Details</value></data>
|
||||
<data name="Server.Copies.Part.Projects" xml:space="preserve"><value>Projects</value></data>
|
||||
<data name="Server.Copies.Part.Plan" xml:space="preserve"><value>Plan</value></data>
|
||||
<data name="Server.Copies.Class.Same" xml:space="preserve"><value>Same</value></data>
|
||||
<data name="Server.Copies.Class.SameUnhashed" xml:space="preserve"><value>Same, unverified</value></data>
|
||||
<data name="Server.Copies.Class.OnlyHere" xml:space="preserve"><value>Only here</value></data>
|
||||
<data name="Server.Copies.Class.OnlyThere" xml:space="preserve"><value>Only there</value></data>
|
||||
<data name="Server.Copies.Class.Differs" xml:space="preserve"><value>Different</value></data>
|
||||
<data name="Server.Copies.Class.Converted" xml:space="preserve"><value>Converted</value></data>
|
||||
<data name="Server.Copies.Class.DeletedHere" xml:space="preserve"><value>Deleted here</value></data>
|
||||
<data name="Server.Copies.Class.DeletedThere" xml:space="preserve"><value>Deleted there</value></data>
|
||||
<data name="Server.Copies.Class.Versions" xml:space="preserve"><value>Two versions</value></data>
|
||||
<data name="Server.Copies.Class.None" xml:space="preserve"><value>No photos differ.</value></data>
|
||||
<data name="Server.Copies.Policy.Label" xml:space="preserve"><value>Photos</value></data>
|
||||
<data name="Server.Copies.Policy.Union" xml:space="preserve"><value>Union</value></data>
|
||||
<data name="Server.Copies.Policy.ChoosePerPhoto" xml:space="preserve"><value>Choose each</value></data>
|
||||
<data name="Server.Copies.Policy.ThisPcWins" xml:space="preserve"><value>This PC wins</value></data>
|
||||
<data name="Server.Copies.Policy.OtherWins" xml:space="preserve"><value>Server wins</value></data>
|
||||
<data name="Server.Copies.Policy.KeptWins" xml:space="preserve"><value>Kept one wins</value></data>
|
||||
<data name="Server.Copies.Policy.OtherCopyWins" xml:space="preserve"><value>Other one wins</value></data>
|
||||
<data name="Server.Copies.Photo.Bring" xml:space="preserve"><value>Bring</value></data>
|
||||
<data name="Server.Copies.Photo.BringAll" xml:space="preserve"><value>Bring all</value></data>
|
||||
<data name="Server.Copies.Photo.BringNone" xml:space="preserve"><value>Bring none</value></data>
|
||||
<data name="Server.Copies.Photo.AllBoth" xml:space="preserve"><value>All: keep both</value></data>
|
||||
<data name="Server.Copies.Photo.Taken" xml:space="preserve"><value>Taken</value></data>
|
||||
<data name="Server.Copies.Photo.Name" xml:space="preserve"><value>Name</value></data>
|
||||
<data name="Server.Copies.Photo.Size" xml:space="preserve"><value>Size</value></data>
|
||||
<data name="Server.Copies.Photo.Side" xml:space="preserve"><value>Where</value></data>
|
||||
<data name="Server.Copies.Version.Both" xml:space="preserve"><value>Keep both</value></data>
|
||||
<data name="Server.Copies.Version.Here" xml:space="preserve"><value>This PC's</value></data>
|
||||
<data name="Server.Copies.Version.There" xml:space="preserve"><value>Server's</value></data>
|
||||
<data name="Server.Copies.Version.Leave" xml:space="preserve"><value>Leave</value></data>
|
||||
<data name="Server.Copies.Detail.ThisPc" xml:space="preserve"><value>This PC</value></data>
|
||||
<data name="Server.Copies.Detail.Server" xml:space="preserve"><value>Server</value></data>
|
||||
<data name="Server.Copies.Detail.Kept" xml:space="preserve"><value>Kept</value></data>
|
||||
<data name="Server.Copies.Detail.Other" xml:space="preserve"><value>Other</value></data>
|
||||
<data name="Server.Copies.Detail.AllThisPc" xml:space="preserve"><value>All this PC</value></data>
|
||||
<data name="Server.Copies.Detail.AllServer" xml:space="preserve"><value>All server</value></data>
|
||||
<data name="Server.Copies.Detail.Positions" xml:space="preserve"><value>Frame positions</value></data>
|
||||
<data name="Server.Copies.Detail.OtherSetting" xml:space="preserve"><value>Other setting</value></data>
|
||||
<data name="Server.Copies.Detail.None" xml:space="preserve"><value>Same details.</value></data>
|
||||
<data name="Server.Copies.Projects.CopyAcross" xml:space="preserve"><value>Copy across</value></data>
|
||||
<data name="Server.Copies.Projects.Leave" xml:space="preserve"><value>Leave them</value></data>
|
||||
<data name="Server.Copies.Projects.Target" xml:space="preserve"><value>→ {0}</value></data>
|
||||
<data name="Server.Copies.Projects.None" xml:space="preserve"><value>No other projects.</value></data>
|
||||
<data name="Server.Copies.Projects.NoneThere" xml:space="preserve"><value>{0} keeps no projects: they stay.</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Projects.Versions.one" xml:space="preserve"><value>{0} version</value></data>
|
||||
<data name="Server.Copies.Projects.Versions.other" xml:space="preserve"><value>{0} versions</value></data>
|
||||
<data name="Server.Copies.Plan.OnThisPc" xml:space="preserve"><value>On this PC</value></data>
|
||||
<data name="Server.Copies.Plan.OnServer" xml:space="preserve"><value>On {0}</value></data>
|
||||
<data name="Server.Copies.Plan.KeptCopy" xml:space="preserve"><value>Kept sequence</value></data>
|
||||
<data name="Server.Copies.Plan.KeptChoice" xml:space="preserve"><value>{0} · {1} · {2}</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Plan.Receives.one" xml:space="preserve"><value>Receives {0} photo · {1}</value></data>
|
||||
<data name="Server.Copies.Plan.Receives.other" xml:space="preserve"><value>Receives {0} photos · {1}</value></data>
|
||||
<data name="Server.Copies.Plan.Sends.one" xml:space="preserve"><value>Sends {0} photo · {1}</value></data>
|
||||
<data name="Server.Copies.Plan.Sends.other" xml:space="preserve"><value>Sends {0} photos · {1}</value></data>
|
||||
<data name="Server.Copies.Plan.Versions.one" xml:space="preserve"><value>Keeps {0} second version</value></data>
|
||||
<data name="Server.Copies.Plan.Versions.other" xml:space="preserve"><value>Keeps {0} second versions</value></data>
|
||||
<data name="Server.Copies.Plan.Trash.one" xml:space="preserve"><value>To trash: {0} photo</value></data>
|
||||
<data name="Server.Copies.Plan.Trash.other" xml:space="preserve"><value>To trash: {0} photos</value></data>
|
||||
<data name="Server.Copies.Plan.LastCopies.one" xml:space="preserve"><value>{0} last copy</value></data>
|
||||
<data name="Server.Copies.Plan.LastCopies.other" xml:space="preserve"><value>{0} last copies</value></data>
|
||||
<data name="Server.Copies.Plan.Details.one" xml:space="preserve"><value>{0} detail changes</value></data>
|
||||
<data name="Server.Copies.Plan.Details.other" xml:space="preserve"><value>{0} details change</value></data>
|
||||
<data name="Server.Copies.Plan.Projects.one" xml:space="preserve"><value>{0} project copied</value></data>
|
||||
<data name="Server.Copies.Plan.Projects.other" xml:space="preserve"><value>{0} projects copied</value></data>
|
||||
<data name="Server.Copies.Plan.Renders.one" xml:space="preserve"><value>{0} render moved</value></data>
|
||||
<data name="Server.Copies.Plan.Renders.other" xml:space="preserve"><value>{0} renders moved</value></data>
|
||||
<data name="Server.Copies.Plan.SessionKeys" xml:space="preserve"><value>Session keys: {0}</value></data>
|
||||
<data name="Server.Copies.Plan.Free" xml:space="preserve"><value>Free: {0}</value></data>
|
||||
<data name="Server.Copies.Plan.Quota" xml:space="preserve"><value>Quota left: {0}</value></data>
|
||||
<data name="Server.Copies.Plan.LeftOut.one" xml:space="preserve"><value>New photos: by hand · {0} left out</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Plan.LeftOut.other" xml:space="preserve"><value>New photos: by hand · {0} left out</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Plan.ServerUsesOurs.one" xml:space="preserve"><value>{1} uses this PC's version of {0} photo</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Plan.ServerUsesOurs.other" xml:space="preserve"><value>{1} uses this PC's version of {0} photos</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Plan.NeedsDelete.one" xml:space="preserve"><value>{0} photo stays: needs the Delete right</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Plan.NeedsDelete.other" xml:space="preserve"><value>{0} photos stay: need the Delete right</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Plan.DropToTrash.one" xml:space="preserve"><value>Other to trash · {0} photo · {1}</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Plan.DropToTrash.other" xml:space="preserve"><value>Other to trash · {0} photos · {1}</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Plan.MovesInto" xml:space="preserve"><value>Photos move into {0}</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Plan.Relink" xml:space="preserve"><value>Linked to {0}: compare again</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Plan.Into" xml:space="preserve"><value>Into {0}</value></data>
|
||||
<data name="Server.Copies.Plan.Nothing" xml:space="preserve"><value>Nothing to move.</value></data>
|
||||
<data name="Server.Copies.Planning" xml:space="preserve"><value>Planning…</value></data>
|
||||
<data name="Server.Copies.Confirm.Replace.Title" xml:space="preserve"><value>Replace photos?</value></data>
|
||||
<data name="Server.Copies.Confirm.Replace.Message.one" xml:space="preserve"><value>{0} photo goes to the trash once the winning version is in place.</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Confirm.Replace.Message.other" xml:space="preserve"><value>{0} photos go to the trash once the winning version is in place.</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Confirm.LastCopy" xml:space="preserve"><value>Only copy: {0}</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Confirm.Merge.Title" xml:space="preserve"><value>Merge sequences?</value></data>
|
||||
<data name="Server.Copies.Confirm.Merge.Message" xml:space="preserve"><value>{0} goes to the trash of {1} after each photo is verified in {2}.</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Confirm.Merge.TypedPrompt" xml:space="preserve"><value>Type the number of photos of {0} to confirm</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Confirm.Merge.OnlyHere.one" xml:space="preserve"><value>{0} photo exists only in {1}</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Confirm.Merge.OnlyHere.other" xml:space="preserve"><value>{0} photos exist only in {1}</value><comment>long</comment></data>
|
||||
<data name="Server.Error.TooMany" xml:space="preserve"><value>The request asked about too many photos at once.</value><comment>long</comment></data>
|
||||
</root>
|
||||
@@ -284,4 +284,11 @@
|
||||
<data name="Settings.Archive.VideosPickTitle" xml:space="preserve"><value>Choose the videos folder</value></data>
|
||||
<data name="Settings.Archive.VideosBrowse" xml:space="preserve"><value>Choose…</value></data>
|
||||
<data name="Settings.Archive.VideosOpen" xml:space="preserve"><value>Open folder</value></data>
|
||||
<data name="Settings.Server.Copies" xml:space="preserve"><value>Matches</value></data>
|
||||
<data name="Settings.Server.CopyLinking" xml:space="preserve"><value>Link matches</value></data>
|
||||
<data name="Settings.Server.CopyLinking.AskAlways" xml:space="preserve"><value>Ask always</value></data>
|
||||
<data name="Settings.Server.CopyLinking.WhenIdentical" xml:space="preserve"><value>When identical</value></data>
|
||||
<data name="Settings.Server.CopyLinking.WhenHalf" xml:space="preserve"><value>Half shared</value></data>
|
||||
<data name="Settings.Server.CopyPhotos" xml:space="preserve"><value>Integrate photos</value></data>
|
||||
<data name="Settings.Server.CopyProjects" xml:space="preserve"><value>Integrate projects</value></data>
|
||||
</root>
|
||||
@@ -1143,4 +1143,106 @@
|
||||
<data name="Tooltips.Settings.VideosBrowse" xml:space="preserve"><value>Choose the videos folder</value></data>
|
||||
<data name="Tooltips.Settings.VideosOpen" xml:space="preserve"><value>Open the videos folder in Explorer</value></data>
|
||||
<data name="Tooltips.Archive.TrashRestoreVideo" xml:space="preserve"><value>Move this video back into its folder after a hash check; its sequence must be in the library</value></data>
|
||||
<data name="Tooltips.Server.Sync.Filter.FoundCopies" xml:space="preserve"><value>Sequences that seem to be the same here and on the server, or twice on this PC.</value></data>
|
||||
<data name="Tooltips.Server.Sync.Show" xml:space="preserve"><value>Show this list.</value></data>
|
||||
<data name="Tooltips.Server.Sync.ShowSkipped" xml:space="preserve"><value>Show the sequences Upload all local left out, first in Local only.</value></data>
|
||||
<data name="Tooltips.Server.Sync.State.CopyFound" xml:space="preserve"><value>This sequence may also be on {0}. Compare to decide.</value></data>
|
||||
<data name="Tooltips.Server.Sync.State.Skipped" xml:space="preserve"><value>Upload all local left this out: {0}.</value></data>
|
||||
<data name="Tooltips.Server.Sync.State.NotSent" xml:space="preserve"><value>Photos did not move by themselves: {0}.</value></data>
|
||||
<data name="Tooltips.Server.Sync.Skip.SuspectedCopy" xml:space="preserve"><value>it may be the same as a sequence on the server</value></data>
|
||||
<data name="Tooltips.Server.Sync.Skip.KeptApart" xml:space="preserve"><value>you kept it apart from a match</value></data>
|
||||
<data name="Tooltips.Server.Sync.Skip.ServerOriginals" xml:space="preserve"><value>it came from a server</value></data>
|
||||
<data name="Tooltips.Server.Sync.Skip.DeletedOnServer" xml:space="preserve"><value>the server deleted its copy</value></data>
|
||||
<data name="Tooltips.Server.Sync.Skip.Busy" xml:space="preserve"><value>it is being integrated</value></data>
|
||||
<data name="Tooltips.Server.Sync.UploadAllSkipping.one" xml:space="preserve"><value>Upload the sequences only here; {0} that may be on the server already is left for review.</value></data>
|
||||
<data name="Tooltips.Server.Sync.UploadAllSkipping.other" xml:space="preserve"><value>Upload the sequences only here; {0} that may be on the server already are left for review.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Find" xml:space="preserve"><value>Look for matches of these sequences on {0} and on this PC now.</value></data>
|
||||
<data name="Tooltips.Server.Copies.FindLocal" xml:space="preserve"><value>Look for matches among this PC's archives now.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Compare" xml:space="preserve"><value>See which photos, details and projects differ between the two sequences.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Integrate" xml:space="preserve"><value>Complete both sequences, settle the differences once, then keep them in sync.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Merge" xml:space="preserve"><value>Merge the two into the kept sequence; the other goes to the trash after verification.</value></data>
|
||||
<data name="Tooltips.Server.Copies.KeepApart" xml:space="preserve"><value>Keep both as separate sequences and stop asking. Upload all local leaves this one out.</value></data>
|
||||
<data name="Tooltips.Server.Copies.LinkOnly" xml:space="preserve"><value>Link the two without moving photos; the next comparison settles equal details.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Unlink" xml:space="preserve"><value>Stop syncing these sequences; nothing is deleted.</value></data>
|
||||
<data name="Tooltips.Server.Copies.UndoUnlink" xml:space="preserve"><value>Link the two again.</value></data>
|
||||
<data name="Tooltips.Server.Copies.UndoKeepApart" xml:space="preserve"><value>Show this match again.</value></data>
|
||||
<data name="Tooltips.Server.Copies.AskAgain" xml:space="preserve"><value>Show this pair as a match again.</value></data>
|
||||
<data name="Tooltips.Server.Copies.UploadAgain" xml:space="preserve"><value>Send this PC's sequence to {0} as a new sequence.</value></data>
|
||||
<data name="Tooltips.Server.Copies.KeepHere" xml:space="preserve"><value>Keep this PC's sequence and stop asking; Upload all local leaves it out.</value></data>
|
||||
<data name="Tooltips.Server.Copies.ToTrash" xml:space="preserve"><value>Move these photos to this PC's archive trash, after a plan you confirm.</value></data>
|
||||
<data name="Tooltips.Server.Copies.ToTrashSequence" xml:space="preserve"><value>Move this PC's sequence to the archive trash; it may be the last copy.</value></data>
|
||||
<data name="Tooltips.Server.Copies.DeleteOnServer" xml:space="preserve"><value>Move these photos to the server's trash, after a plan you confirm.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Review" xml:space="preserve"><value>Open the comparison at the photos deleted on the other side.</value></data>
|
||||
<data name="Tooltips.Server.Copies.ReviewFound" xml:space="preserve"><value>Open the list of matches found.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Drop" xml:space="preserve"><value>Move this version to the trash of each side that holds it.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Choose" xml:space="preserve"><value>Go to the choices still missing.</value></data>
|
||||
<data name="Tooltips.Server.Copies.State.Candidate" xml:space="preserve"><value>{0} % of the photos are shared. Compare to decide.</value></data>
|
||||
<data name="Tooltips.Server.Copies.State.KeptApart" xml:space="preserve"><value>You chose to keep these apart on {0}.</value></data>
|
||||
<data name="Tooltips.Server.Copies.State.Linked" xml:space="preserve"><value>Linked: sync compares them; photos move on Upload and Download.</value></data>
|
||||
<data name="Tooltips.Server.Copies.State.Integrating" xml:space="preserve"><value>Being integrated; the job shows each step.</value></data>
|
||||
<data name="Tooltips.Server.Copies.State.Integrated" xml:space="preserve"><value>New photos move both ways by themselves; deletions wait for you.</value></data>
|
||||
<data name="Tooltips.Server.Copies.State.RemoteGone" xml:space="preserve"><value>The server deleted its copy; this PC's sequence is unchanged.</value></data>
|
||||
<data name="Tooltips.Server.Copies.State.KeptHere" xml:space="preserve"><value>You kept this PC's sequence after the server deleted its copy.</value></data>
|
||||
<data name="Tooltips.Server.Copies.State.DeletedThere.one" xml:space="preserve"><value>{0} photo was deleted on the other side; it stays here until you choose.</value></data>
|
||||
<data name="Tooltips.Server.Copies.State.DeletedThere.other" xml:space="preserve"><value>{0} photos were deleted on the other side; they stay here until you choose.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Class.Same" xml:space="preserve"><value>The same files on both sides, by SHA-256.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Class.SameUnhashed" xml:space="preserve"><value>Same size and capture time; one side is not verified yet. A merge checks them by hash first.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Class.OnlyHere" xml:space="preserve"><value>Photos only this side holds; Integrate copies them to the other.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Class.OnlyThere" xml:space="preserve"><value>Photos only the other side holds; Integrate copies them here.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Class.Differs" xml:space="preserve"><value>Same name and capture time, different files. Union keeps both versions.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Class.Converted" xml:space="preserve"><value>The same photo in another encoding; counted as one.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Class.DeletedHere" xml:space="preserve"><value>Deleted on this side, still on the other. Never brought back.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Class.DeletedThere" xml:space="preserve"><value>Deleted on the other side, still here. Nothing is deleted unless you confirm.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Class.Versions" xml:space="preserve"><value>Two files of one capture time; the other side's is excluded in Main.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Policy" xml:space="preserve"><value>The photo choice for this run; Settings › Server gives the default.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Policy.Union" xml:space="preserve"><value>Every photo of both sequences ends up in both; differing ones keep both versions.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Policy.ChoosePerPhoto" xml:space="preserve"><value>You tick which photos to bring; nothing is preselected.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Policy.ThisPcWins" xml:space="preserve"><value>Photos only on one side go to both; for different photos this PC's version replaces the server's, which goes to the trash.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Policy.OtherWins" xml:space="preserve"><value>Photos only on one side go to both; for different photos the server's version replaces this PC's, which goes to the trash.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Policy.KeptWins" xml:space="preserve"><value>Every photo of the other joins the kept one; for different photos the kept version stays.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Policy.OtherCopyWins" xml:space="preserve"><value>Every photo of the other joins the kept one; for different photos the other's version replaces the kept one's, which goes to the trash.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Bring" xml:space="preserve"><value>Copy this photo to the other side.</value></data>
|
||||
<data name="Tooltips.Server.Copies.BringAll" xml:space="preserve"><value>Tick every photo of this list.</value></data>
|
||||
<data name="Tooltips.Server.Copies.BringNone" xml:space="preserve"><value>Untick every photo of this list.</value></data>
|
||||
<data name="Tooltips.Server.Copies.AllBoth" xml:space="preserve"><value>Keep both versions of every different photo.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Version" xml:space="preserve"><value>What to do with these two different files of one capture time.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Detail" xml:space="preserve"><value>The value both sequences take.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Detail.All" xml:space="preserve"><value>Take this side's value for every difference.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Projects.CopyAcross" xml:space="preserve"><value>Each side's other projects appear on the other home with their history, renamed on a clash.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Projects.Leave" xml:space="preserve"><value>Other projects stay where they are; Edit marks the two workspace copies as twins.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Projects.MergeAlways" xml:space="preserve"><value>A merge always copies the other's projects: its home goes to the trash.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Projects.Main" xml:space="preserve"><value>Main follows the details you choose.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Plan.Free" xml:space="preserve"><value>Free space where the photos are filed; the trash frees space only once emptied.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Plan.Quota" xml:space="preserve"><value>What your account may still store on the server.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Plan.LastCopies" xml:space="preserve"><value>These photos exist nowhere else; they go to the trash and can be restored from there.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Plan.LeftOut" xml:space="preserve"><value>Photos you left out stay on one side, so new photos keep moving only on Upload and Download.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Plan.ServerUsesOurs" xml:space="preserve"><value>The server's Main switches to this PC's version of each different photo; its renders of them change.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Plan.SessionKeys" xml:space="preserve"><value>Later imports of the same card or folder join the kept sequence. Keys the archive already uses stay: {0}.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Plan.Relink" xml:space="preserve"><value>The link moves to the kept sequence; the next comparison settles equal details or shows a conflict.</value></data>
|
||||
<data name="Tooltips.Server.Copies.KeptCopy" xml:space="preserve"><value>The sequence that stays; the other's photos join it.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Cancel" xml:space="preserve"><value>Close without changing anything.</value></data>
|
||||
<data name="Tooltips.Server.Copies.LinkTaken" xml:space="preserve"><value>One of these sequences is already linked to another sequence of {0}.</value></data>
|
||||
<data name="Tooltips.Server.Copies.NeedsNewerServer" xml:space="preserve"><value>This server needs an update to integrate sequences.</value></data>
|
||||
<data name="Tooltips.Server.Copies.SignIn" xml:space="preserve"><value>Sign in to {0} to act on this pair.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Confirm.Safe" xml:space="preserve"><value>Close without changing anything.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Confirm.Replace.Action" xml:space="preserve"><value>Integrate, then move the replaced versions to the trash.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Confirm.Merge.Action" xml:space="preserve"><value>Merge, then move the other sequence to the trash after verification.</value></data>
|
||||
<data name="Tooltips.Jobs.OpenMatch" xml:space="preserve"><value>Show the sequences this job worked on.</value></data>
|
||||
<data name="Tooltips.Library.Status.CopyFound" xml:space="preserve"><value>Also on {0} · {1} % shared.</value></data>
|
||||
<data name="Tooltips.Library.Status.CopyFoundLocal" xml:space="preserve"><value>Also in {0}.</value></data>
|
||||
<data name="Tooltips.Library.Status.DeletedThere" xml:space="preserve"><value>Photos of this sequence were deleted on {0}; they stay here until you choose.</value></data>
|
||||
<data name="Tooltips.Library.Compare" xml:space="preserve"><value>Compare this sequence with its match.</value></data>
|
||||
<data name="Tooltips.Editor.Picker.Twin" xml:space="preserve"><value>Also at {0}: {1}.</value></data>
|
||||
<data name="Tooltips.Settings.CopyLinking" xml:space="preserve"><value>What Chronos does with two copies of one sequence it finds. Linked sequences stay in sync.</value></data>
|
||||
<data name="Tooltips.Settings.CopyLinking.AskAlways" xml:space="preserve"><value>Show every match; nothing is linked until you choose.</value></data>
|
||||
<data name="Tooltips.Settings.CopyLinking.WhenIdentical" xml:space="preserve"><value>Link sequences with exactly the same photos by themselves; ask for the others.</value></data>
|
||||
<data name="Tooltips.Settings.CopyLinking.WhenHalf" xml:space="preserve"><value>Link sequences that start in the same second with the same camera and share at least half of their photos, as Chronos 1.1 did.</value></data>
|
||||
<data name="Tooltips.Settings.CopyPhotos" xml:space="preserve"><value>The photo choice an Integrate starts from; you can change it each time.</value></data>
|
||||
<data name="Tooltips.Settings.CopyPhotos.Union" xml:space="preserve"><value>Every photo of both sequences ends up in both; differing ones keep both versions.</value></data>
|
||||
<data name="Tooltips.Settings.CopyPhotos.ChoosePerPhoto" xml:space="preserve"><value>You tick which photos to bring; nothing is preselected.</value></data>
|
||||
<data name="Tooltips.Settings.CopyPhotos.ThisPcWins" xml:space="preserve"><value>Photos only on one side go to both; for different photos this PC's version replaces the server's, which goes to the trash.</value></data>
|
||||
<data name="Tooltips.Settings.CopyPhotos.OtherWins" xml:space="preserve"><value>Photos only on one side go to both; for different photos the server's version replaces this PC's, which goes to the trash.</value></data>
|
||||
<data name="Tooltips.Settings.CopyProjects" xml:space="preserve"><value>Whether an Integrate copies the other projects to the other home, renamed on a clash.</value></data>
|
||||
<data name="Tooltips.Settings.CopyProjects.CopyAcross" xml:space="preserve"><value>Each side's other projects appear on the other home with their history, renamed on a clash.</value></data>
|
||||
<data name="Tooltips.Settings.CopyProjects.Leave" xml:space="preserve"><value>Other projects stay where they are; Edit marks the two workspace copies as twins.</value></data>
|
||||
</root>
|
||||
@@ -1239,4 +1239,9 @@
|
||||
<data name="Admin.Job.Speed.PerSecond" xml:space="preserve"><value>{0}/s</value></data>
|
||||
<data name="Admin.Job.Speed.Bytes" xml:space="preserve"><value>{0}/s</value></data>
|
||||
<data name="Admin.Job.Left" xml:space="preserve"><value>{0} rimanenti</value></data>
|
||||
<data name="Admin.Job.Kind.Integrate" xml:space="preserve"><value>Integra sequenze</value></data>
|
||||
<data name="Admin.Job.Kind.MergeSequences" xml:space="preserve"><value>Unisci sequenze</value></data>
|
||||
<data name="Admin.Job.Step.Details" xml:space="preserve"><value>Allineamento dettagli</value></data>
|
||||
<data name="Admin.Job.Step.Projects" xml:space="preserve"><value>Copia dei progetti</value></data>
|
||||
<data name="Admin.Job.Step.Trash" xml:space="preserve"><value>Spostamento nel cestino</value></data>
|
||||
</root>
|
||||
@@ -446,4 +446,10 @@
|
||||
<data name="Archive.Log.WorkspaceSendNoProvenance" xml:space="preserve"><value>{0}: il server ha tenuto il render senza il suo progetto; aggiorna il server per tenerlo</value></data>
|
||||
<data name="Archive.Log.WorkspaceMoveLeft" xml:space="preserve"><value>Spostato; {0} contiene ancora {1} elementi che non è stato possibile eliminare</value></data>
|
||||
<data name="Archive.Trash.Kind.Videos" xml:space="preserve"><value>Video</value></data>
|
||||
<data name="Archive.Log.CopySent" xml:space="preserve"><value>{0}: inviata nella sequenza collegata</value></data>
|
||||
<data name="Archive.Log.CopyFetched" xml:space="preserve"><value>{0}: ricevuta nella sequenza di questo PC</value></data>
|
||||
<data name="Archive.Log.CopyReplaced" xml:space="preserve"><value>{0}: versione precedente nel cestino</value></data>
|
||||
<data name="Archive.Log.CopyProject" xml:space="preserve"><value>Progetto {0} copiato come {1}</value></data>
|
||||
<data name="Archive.Log.MergeCopied" xml:space="preserve"><value>{0}: copiata e verificata</value></data>
|
||||
<data name="Archive.Log.MergeTrashed" xml:space="preserve"><value>{0} spostata nel cestino</value></data>
|
||||
</root>
|
||||
@@ -467,4 +467,5 @@
|
||||
<data name="Editor.Workspace.Undo" xml:space="preserve"><value>Annulla</value></data>
|
||||
<data name="Editor.Workspace.UpdateMedia" xml:space="preserve"><value>Aggiorna media</value></data>
|
||||
<data name="Editor.Workspace.Updating" xml:space="preserve"><value>Aggiornamento media</value></data>
|
||||
<data name="Editor.Picker.Twin" xml:space="preserve"><value>Gemella</value></data>
|
||||
</root>
|
||||
@@ -133,4 +133,32 @@
|
||||
<data name="Errors.Videos.TrashMismatch" xml:space="preserve"><value>Il video nel cestino non corrisponde più al suo registro; resta nel cestino.</value></data>
|
||||
<data name="Errors.Videos.Busy" xml:space="preserve"><value>Un'attività sta usando {0}; riprova quando finisce.</value></data>
|
||||
<data name="Errors.Videos.CannotPlay" xml:space="preserve"><value>Windows non sa decodificare questo file qui; Mostra nella cartella apre la sua cartella.</value></data>
|
||||
<data name="Errors.Copies.StalePlan" xml:space="preserve"><value>Le sequenze sono cambiate dopo il piano: confrontale di nuovo.</value></data>
|
||||
<data name="Errors.Copies.LinkTaken" xml:space="preserve"><value>{0} è già collegata a un'altra sequenza di {1}.</value></data>
|
||||
<data name="Errors.Copies.DetailsChanged" xml:space="preserve"><value>I dettagli sono cambiati su un lato nel frattempo; le foto sono al loro posto, confronta di nuovo.</value></data>
|
||||
<data name="Errors.Copies.Changed" xml:space="preserve"><value>{0} è cambiata durante l'unione; nulla è andato nel cestino.</value></data>
|
||||
<data name="Errors.Copies.ChangedFile" xml:space="preserve"><value>{0} non corrisponde più al suo hash; nulla è andato nel cestino. Esegui Verifica.</value></data>
|
||||
<data name="Errors.Copies.RemoteGone" xml:space="preserve"><value>Il server ha eliminato la sua sequenza nel frattempo; non è stato inviato altro.</value></data>
|
||||
<data name="Errors.Copies.VerifyFailed.one" xml:space="preserve"><value>{0} foto non corrisponde dopo la copia: nulla è andato nel cestino.</value></data>
|
||||
<data name="Errors.Copies.VerifyFailed.other" xml:space="preserve"><value>{0} foto non corrispondono dopo la copia: nulla è andato nel cestino.</value></data>
|
||||
<data name="Errors.Copies.Kept.one" xml:space="preserve"><value>{0} foto è rimasta com'era; il registro del lavoro dice perché.</value></data>
|
||||
<data name="Errors.Copies.Kept.other" xml:space="preserve"><value>{0} foto sono rimaste com'erano; il registro del lavoro dice perché.</value></data>
|
||||
<data name="Errors.Copies.ProjectsKept.one" xml:space="preserve"><value>{0} progetto non è stato copiato; il registro dice perché.</value></data>
|
||||
<data name="Errors.Copies.ProjectsKept.other" xml:space="preserve"><value>{0} progetti non sono stati copiati; il registro dice perché.</value></data>
|
||||
<data name="Errors.Copies.NoSpace" xml:space="preserve"><value>{0} ha bisogno di {1} liberi; libera spazio e riprova.</value></data>
|
||||
<data name="Errors.Copies.Busy" xml:space="preserve"><value>Un lavoro sta usando una di queste sequenze; riprova quando finisce.</value></data>
|
||||
<data name="Errors.Copies.Unsent" xml:space="preserve"><value>Prima invia o scarta le modifiche di lavoro di {0}.</value></data>
|
||||
<data name="Errors.Copies.BothLinked" xml:space="preserve"><value>Entrambe le sequenze sono collegate a {0}: integrale prima lì.</value></data>
|
||||
<data name="Errors.Copies.TrashBlocked" xml:space="preserve"><value>{0} non può andare nel cestino: {1}</value></data>
|
||||
<data name="Errors.Copies.DetailsUnchosen.one" xml:space="preserve"><value>Prima scegli {0} dettaglio.</value></data>
|
||||
<data name="Errors.Copies.DetailsUnchosen.other" xml:space="preserve"><value>Prima scegli {0} dettagli.</value></data>
|
||||
<data name="Errors.Copies.KeptUnchosen" xml:space="preserve"><value>Scegli la sequenza da tenere.</value></data>
|
||||
<data name="Errors.Copies.NeedsNewerServer" xml:space="preserve"><value>{0} va aggiornato per integrare le sequenze.</value></data>
|
||||
<data name="Errors.Copies.NoUploadRight" xml:space="preserve"><value>L'account del server non può caricare foto.</value></data>
|
||||
<data name="Errors.Copies.NoFetchRight" xml:space="preserve"><value>L'account del server non può scaricare gli originali.</value></data>
|
||||
<data name="Errors.Copies.NoEditRight" xml:space="preserve"><value>L'account del server non può cambiare i dettagli.</value></data>
|
||||
<data name="Errors.Copies.NoDeleteRight" xml:space="preserve"><value>L'account del server non può eliminare queste foto.</value></data>
|
||||
<data name="Errors.Copies.ArchiveOffline" xml:space="preserve"><value>L'archivio di {0} non è raggiungibile; collegalo e riprova.</value></data>
|
||||
<data name="Errors.Copies.FolderMoved" xml:space="preserve"><value>{0} non è dove l'indice la colloca; riprova dopo la prossima scansione.</value></data>
|
||||
<data name="Errors.Copies.NotThere" xml:space="preserve"><value>L'altro lato non ha più eliminato queste foto; nulla è andato nel cestino.</value></data>
|
||||
</root>
|
||||
@@ -254,4 +254,11 @@
|
||||
<data name="Jobs.Part.Step" xml:space="preserve"><value>passo {0} di {1}</value></data>
|
||||
<data name="Jobs.Detail.Count" xml:space="preserve"><value>{0} di {1}</value></data>
|
||||
<data name="Jobs.Detail.StoppedAt" xml:space="preserve"><value>Fermo a {0}</value></data>
|
||||
<data name="Jobs.Kind.Integrate" xml:space="preserve"><value>Integra sequenze</value></data>
|
||||
<data name="Jobs.Kind.MergeSequences" xml:space="preserve"><value>Unisci sequenze</value></data>
|
||||
<data name="Jobs.Target.Integrate" xml:space="preserve"><value>Integra {0}</value></data>
|
||||
<data name="Jobs.Target.Merge" xml:space="preserve"><value>Unisci in {0}</value></data>
|
||||
<data name="Jobs.Step.Details" xml:space="preserve"><value>Allineamento dettagli</value></data>
|
||||
<data name="Jobs.Step.Projects" xml:space="preserve"><value>Copia dei progetti</value></data>
|
||||
<data name="Jobs.Step.Trash" xml:space="preserve"><value>Spostamento nel cestino</value></data>
|
||||
</root>
|
||||
@@ -125,4 +125,7 @@
|
||||
<data name="Library.Views.SaveMenu" xml:space="preserve"><value>Salva vista…</value></data>
|
||||
<data name="Library.Views.Saved" xml:space="preserve"><value>Vista {0} salvata</value></data>
|
||||
<data name="Library.Views.Undo" xml:space="preserve"><value>Annulla</value></data>
|
||||
<data name="Library.Status.CopyFound" xml:space="preserve"><value>Anche altrove</value></data>
|
||||
<data name="Library.Status.DeletedThere" xml:space="preserve"><value>Eliminate là</value></data>
|
||||
<data name="Library.Action.Compare" xml:space="preserve"><value>Confronta…</value></data>
|
||||
</root>
|
||||
@@ -292,4 +292,158 @@
|
||||
<data name="Server.Error.TrashHashMismatch" xml:space="preserve"><value>Il video nel cestino non corrisponde più al suo registro; resta nel cestino.</value></data>
|
||||
<data name="Server.Error.SequenceGone" xml:space="preserve"><value>La sequenza del video non è nella libreria: ripristina prima la sequenza.</value></data>
|
||||
<data name="Server.Error.VideoBusy" xml:space="preserve"><value>Un'attività sta usando questo video; riprova quando finisce.</value></data>
|
||||
<data name="Server.Sync.Filter.FoundCopies" xml:space="preserve"><value>Corrispondenze · {0}</value></data>
|
||||
<data name="Server.Sync.QueuedSkipped" xml:space="preserve"><value>In coda: {0} · saltate: {1}</value></data>
|
||||
<data name="Server.Sync.Show" xml:space="preserve"><value>Mostra</value></data>
|
||||
<data name="Server.Sync.State.CopyFound" xml:space="preserve"><value>corrispondenza trovata</value></data>
|
||||
<data name="Server.Sync.State.RemoteGone" xml:space="preserve"><value>eliminata sul server</value></data>
|
||||
<data name="Server.Sync.State.KeptHere" xml:space="preserve"><value>tenuta qui</value></data>
|
||||
<data name="Server.Sync.State.Skipped" xml:space="preserve"><value>saltata</value></data>
|
||||
<data name="Server.Sync.State.NotSent" xml:space="preserve"><value>non inviata</value></data>
|
||||
<data name="Server.Sync.NotSentToast" xml:space="preserve"><value>{0}: foto non inviate</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Column.Sequence" xml:space="preserve"><value>Sequenza</value></data>
|
||||
<data name="Server.Copies.Column.ThisSide" xml:space="preserve"><value>Questo lato</value></data>
|
||||
<data name="Server.Copies.Column.OtherSide" xml:space="preserve"><value>Altro lato</value></data>
|
||||
<data name="Server.Copies.Column.State" xml:space="preserve"><value>Stato</value></data>
|
||||
<data name="Server.Copies.State.Candidate" xml:space="preserve"><value>corrispondenza trovata</value></data>
|
||||
<data name="Server.Copies.State.KeptApart" xml:space="preserve"><value>tenute separate</value></data>
|
||||
<data name="Server.Copies.State.Linked" xml:space="preserve"><value>collegate</value></data>
|
||||
<data name="Server.Copies.State.Integrating" xml:space="preserve"><value>in integrazione · {0} di {1}</value></data>
|
||||
<data name="Server.Copies.State.Integrated" xml:space="preserve"><value>integrate</value></data>
|
||||
<data name="Server.Copies.State.RemoteGone" xml:space="preserve"><value>eliminata sul server</value></data>
|
||||
<data name="Server.Copies.State.KeptHere" xml:space="preserve"><value>tenuta qui</value></data>
|
||||
<data name="Server.Copies.State.DeletedThere" xml:space="preserve"><value>eliminate là · {0}</value></data>
|
||||
<data name="Server.Copies.State.DeletedOther" xml:space="preserve"><value>eliminate nell'altra · {0}</value></data>
|
||||
<data name="Server.Copies.Action.Compare" xml:space="preserve"><value>Confronta…</value></data>
|
||||
<data name="Server.Copies.Action.Integrate" xml:space="preserve"><value>Integra…</value></data>
|
||||
<data name="Server.Copies.Action.MergeRow" xml:space="preserve"><value>Unisci…</value></data>
|
||||
<data name="Server.Copies.Action.IntegrateNow" xml:space="preserve"><value>Integra</value></data>
|
||||
<data name="Server.Copies.Action.Merge" xml:space="preserve"><value>Unisci</value></data>
|
||||
<data name="Server.Copies.Action.KeepApart" xml:space="preserve"><value>Tieni separate</value></data>
|
||||
<data name="Server.Copies.Action.LinkOnly" xml:space="preserve"><value>Collega soltanto</value></data>
|
||||
<data name="Server.Copies.Action.Unlink" xml:space="preserve"><value>Scollega</value></data>
|
||||
<data name="Server.Copies.Action.Undo" xml:space="preserve"><value>Annulla</value></data>
|
||||
<data name="Server.Copies.Action.AskAgain" xml:space="preserve"><value>Chiedi di nuovo</value></data>
|
||||
<data name="Server.Copies.Action.Find" xml:space="preserve"><value>Cerca corrispondenze</value></data>
|
||||
<data name="Server.Copies.Action.UploadAgain" xml:space="preserve"><value>Carica di nuovo</value></data>
|
||||
<data name="Server.Copies.Action.KeepHere" xml:space="preserve"><value>Tieni qui</value></data>
|
||||
<data name="Server.Copies.Action.ToTrash" xml:space="preserve"><value>Nel cestino…</value></data>
|
||||
<data name="Server.Copies.Action.DeleteOnServer" xml:space="preserve"><value>Elimina sul server…</value></data>
|
||||
<data name="Server.Copies.Action.Review" xml:space="preserve"><value>Rivedi</value></data>
|
||||
<data name="Server.Copies.Action.Drop" xml:space="preserve"><value>Scarta…</value></data>
|
||||
<data name="Server.Copies.Action.Choose" xml:space="preserve"><value>Scegli</value></data>
|
||||
<data name="Server.Copies.Empty" xml:space="preserve"><value>Nessuna corrispondenza trovata.</value></data>
|
||||
<data name="Server.Copies.ControlFor" xml:space="preserve"><value>{0}: {1}</value></data>
|
||||
<data name="Server.Copies.Where.ThisPc" xml:space="preserve"><value>Questo PC · {0}</value></data>
|
||||
<data name="Server.Copies.Where.Archive.one" xml:space="preserve"><value>{1} · {0} foto</value></data>
|
||||
<data name="Server.Copies.Where.Archive.other" xml:space="preserve"><value>{1} · {0} foto</value></data>
|
||||
<data name="Server.Copies.Where.Server.one" xml:space="preserve"><value>{1} · {0} foto</value></data>
|
||||
<data name="Server.Copies.Where.Server.other" xml:space="preserve"><value>{1} · {0} foto</value></data>
|
||||
<data name="Server.Copies.Facts.one" xml:space="preserve"><value>{1} · {0} foto · {2}</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Facts.other" xml:space="preserve"><value>{1} · {0} foto · {2}</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Found.one" xml:space="preserve"><value>{0} corrispondenza trovata</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Found.other" xml:space="preserve"><value>{0} corrispondenze trovate</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Linked.one" xml:space="preserve"><value>{0} sequenza collegata</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Linked.other" xml:space="preserve"><value>{0} sequenze collegate</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Unlinked" xml:space="preserve"><value>{0} scollegata</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.KeptApartToast" xml:space="preserve"><value>Tenute separate: {0}</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.DeletedToast.one" xml:space="preserve"><value>{0} foto eliminata su {1}</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.DeletedToast.other" xml:space="preserve"><value>{0} foto eliminate su {1}</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Dialog.Compare" xml:space="preserve"><value>Confronta sequenze</value></data>
|
||||
<data name="Server.Copies.Dialog.Merge" xml:space="preserve"><value>Unisci sequenze</value></data>
|
||||
<data name="Server.Copies.Part.Photos" xml:space="preserve"><value>Foto</value></data>
|
||||
<data name="Server.Copies.Part.Details" xml:space="preserve"><value>Dettagli</value></data>
|
||||
<data name="Server.Copies.Part.Projects" xml:space="preserve"><value>Progetti</value></data>
|
||||
<data name="Server.Copies.Part.Plan" xml:space="preserve"><value>Piano</value></data>
|
||||
<data name="Server.Copies.Class.Same" xml:space="preserve"><value>Uguali</value></data>
|
||||
<data name="Server.Copies.Class.SameUnhashed" xml:space="preserve"><value>Uguali, non verificate</value></data>
|
||||
<data name="Server.Copies.Class.OnlyHere" xml:space="preserve"><value>Solo qui</value></data>
|
||||
<data name="Server.Copies.Class.OnlyThere" xml:space="preserve"><value>Solo là</value></data>
|
||||
<data name="Server.Copies.Class.Differs" xml:space="preserve"><value>Diverse</value></data>
|
||||
<data name="Server.Copies.Class.Converted" xml:space="preserve"><value>Convertite</value></data>
|
||||
<data name="Server.Copies.Class.DeletedHere" xml:space="preserve"><value>Eliminate qui</value></data>
|
||||
<data name="Server.Copies.Class.DeletedThere" xml:space="preserve"><value>Eliminate là</value></data>
|
||||
<data name="Server.Copies.Class.Versions" xml:space="preserve"><value>Due versioni</value></data>
|
||||
<data name="Server.Copies.Class.None" xml:space="preserve"><value>Nessuna foto diversa.</value></data>
|
||||
<data name="Server.Copies.Policy.Label" xml:space="preserve"><value>Foto</value></data>
|
||||
<data name="Server.Copies.Policy.Union" xml:space="preserve"><value>Unione</value></data>
|
||||
<data name="Server.Copies.Policy.ChoosePerPhoto" xml:space="preserve"><value>Scegli singolarmente</value></data>
|
||||
<data name="Server.Copies.Policy.ThisPcWins" xml:space="preserve"><value>Vince questo PC</value></data>
|
||||
<data name="Server.Copies.Policy.OtherWins" xml:space="preserve"><value>Vince il server</value></data>
|
||||
<data name="Server.Copies.Policy.KeptWins" xml:space="preserve"><value>Vince quella tenuta</value></data>
|
||||
<data name="Server.Copies.Policy.OtherCopyWins" xml:space="preserve"><value>Vince l'altra</value></data>
|
||||
<data name="Server.Copies.Photo.Bring" xml:space="preserve"><value>Porta</value></data>
|
||||
<data name="Server.Copies.Photo.BringAll" xml:space="preserve"><value>Porta tutte</value></data>
|
||||
<data name="Server.Copies.Photo.BringNone" xml:space="preserve"><value>Nessuna</value></data>
|
||||
<data name="Server.Copies.Photo.AllBoth" xml:space="preserve"><value>Tutte: entrambe</value></data>
|
||||
<data name="Server.Copies.Photo.Taken" xml:space="preserve"><value>Scatto</value></data>
|
||||
<data name="Server.Copies.Photo.Name" xml:space="preserve"><value>Nome</value></data>
|
||||
<data name="Server.Copies.Photo.Size" xml:space="preserve"><value>Dimensione</value></data>
|
||||
<data name="Server.Copies.Photo.Side" xml:space="preserve"><value>Dove</value></data>
|
||||
<data name="Server.Copies.Version.Both" xml:space="preserve"><value>Tienile entrambe</value></data>
|
||||
<data name="Server.Copies.Version.Here" xml:space="preserve"><value>Di questo PC</value></data>
|
||||
<data name="Server.Copies.Version.There" xml:space="preserve"><value>Del server</value></data>
|
||||
<data name="Server.Copies.Version.Leave" xml:space="preserve"><value>Lascia</value></data>
|
||||
<data name="Server.Copies.Detail.ThisPc" xml:space="preserve"><value>Questo PC</value></data>
|
||||
<data name="Server.Copies.Detail.Server" xml:space="preserve"><value>Server</value></data>
|
||||
<data name="Server.Copies.Detail.Kept" xml:space="preserve"><value>Tenuta</value></data>
|
||||
<data name="Server.Copies.Detail.Other" xml:space="preserve"><value>Altra</value></data>
|
||||
<data name="Server.Copies.Detail.AllThisPc" xml:space="preserve"><value>Tutte da qui</value></data>
|
||||
<data name="Server.Copies.Detail.AllServer" xml:space="preserve"><value>Tutte dal server</value></data>
|
||||
<data name="Server.Copies.Detail.Positions" xml:space="preserve"><value>Posizioni fotogrammi</value></data>
|
||||
<data name="Server.Copies.Detail.OtherSetting" xml:space="preserve"><value>Altra impostazione</value></data>
|
||||
<data name="Server.Copies.Detail.None" xml:space="preserve"><value>Dettagli uguali.</value></data>
|
||||
<data name="Server.Copies.Projects.CopyAcross" xml:space="preserve"><value>Copia dall'altra parte</value></data>
|
||||
<data name="Server.Copies.Projects.Leave" xml:space="preserve"><value>Lasciali dove sono</value></data>
|
||||
<data name="Server.Copies.Projects.Target" xml:space="preserve"><value>→ {0}</value></data>
|
||||
<data name="Server.Copies.Projects.None" xml:space="preserve"><value>Nessun altro progetto.</value></data>
|
||||
<data name="Server.Copies.Projects.NoneThere" xml:space="preserve"><value>{0} non tiene progetti: restano dove sono.</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Projects.Versions.one" xml:space="preserve"><value>{0} versione</value></data>
|
||||
<data name="Server.Copies.Projects.Versions.other" xml:space="preserve"><value>{0} versioni</value></data>
|
||||
<data name="Server.Copies.Plan.OnThisPc" xml:space="preserve"><value>Su questo PC</value></data>
|
||||
<data name="Server.Copies.Plan.OnServer" xml:space="preserve"><value>Su {0}</value></data>
|
||||
<data name="Server.Copies.Plan.KeptCopy" xml:space="preserve"><value>Sequenza tenuta</value></data>
|
||||
<data name="Server.Copies.Plan.KeptChoice" xml:space="preserve"><value>{0} · {1} · {2}</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Plan.Receives.one" xml:space="preserve"><value>Riceve {0} foto · {1}</value></data>
|
||||
<data name="Server.Copies.Plan.Receives.other" xml:space="preserve"><value>Riceve {0} foto · {1}</value></data>
|
||||
<data name="Server.Copies.Plan.Sends.one" xml:space="preserve"><value>Invia {0} foto · {1}</value></data>
|
||||
<data name="Server.Copies.Plan.Sends.other" xml:space="preserve"><value>Invia {0} foto · {1}</value></data>
|
||||
<data name="Server.Copies.Plan.Versions.one" xml:space="preserve"><value>Tiene {0} seconda versione</value></data>
|
||||
<data name="Server.Copies.Plan.Versions.other" xml:space="preserve"><value>Tiene {0} seconde versioni</value></data>
|
||||
<data name="Server.Copies.Plan.Trash.one" xml:space="preserve"><value>Nel cestino: {0} foto</value></data>
|
||||
<data name="Server.Copies.Plan.Trash.other" xml:space="preserve"><value>Nel cestino: {0} foto</value></data>
|
||||
<data name="Server.Copies.Plan.LastCopies.one" xml:space="preserve"><value>{0} unica copia</value></data>
|
||||
<data name="Server.Copies.Plan.LastCopies.other" xml:space="preserve"><value>{0} uniche copie</value></data>
|
||||
<data name="Server.Copies.Plan.Details.one" xml:space="preserve"><value>{0} dettaglio cambia</value></data>
|
||||
<data name="Server.Copies.Plan.Details.other" xml:space="preserve"><value>{0} dettagli cambiano</value></data>
|
||||
<data name="Server.Copies.Plan.Projects.one" xml:space="preserve"><value>{0} progetto copiato</value></data>
|
||||
<data name="Server.Copies.Plan.Projects.other" xml:space="preserve"><value>{0} progetti copiati</value></data>
|
||||
<data name="Server.Copies.Plan.Renders.one" xml:space="preserve"><value>{0} video spostato</value></data>
|
||||
<data name="Server.Copies.Plan.Renders.other" xml:space="preserve"><value>{0} video spostati</value></data>
|
||||
<data name="Server.Copies.Plan.SessionKeys" xml:space="preserve"><value>Chiavi di sessione: {0}</value></data>
|
||||
<data name="Server.Copies.Plan.Free" xml:space="preserve"><value>Libero: {0}</value></data>
|
||||
<data name="Server.Copies.Plan.Quota" xml:space="preserve"><value>Quota residua: {0}</value></data>
|
||||
<data name="Server.Copies.Plan.LeftOut.one" xml:space="preserve"><value>Foto nuove: a mano · {0} esclusa</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Plan.LeftOut.other" xml:space="preserve"><value>Foto nuove: a mano · {0} escluse</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Plan.ServerUsesOurs.one" xml:space="preserve"><value>{1} usa la versione di questo PC di {0} foto</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Plan.ServerUsesOurs.other" xml:space="preserve"><value>{1} usa la versione di questo PC di {0} foto</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Plan.NeedsDelete.one" xml:space="preserve"><value>{0} foto resta: serve il permesso Elimina</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Plan.NeedsDelete.other" xml:space="preserve"><value>{0} foto restano: serve il permesso Elimina</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Plan.DropToTrash.one" xml:space="preserve"><value>Altra nel cestino · {0} foto · {1}</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Plan.DropToTrash.other" xml:space="preserve"><value>Altra nel cestino · {0} foto · {1}</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Plan.MovesInto" xml:space="preserve"><value>Le foto passano in {0}</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Plan.Relink" xml:space="preserve"><value>Collegata a {0}: confronta di nuovo</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Plan.Into" xml:space="preserve"><value>In {0}</value></data>
|
||||
<data name="Server.Copies.Plan.Nothing" xml:space="preserve"><value>Niente da spostare.</value></data>
|
||||
<data name="Server.Copies.Planning" xml:space="preserve"><value>Pianificazione…</value></data>
|
||||
<data name="Server.Copies.Confirm.Replace.Title" xml:space="preserve"><value>Sostituire le foto?</value></data>
|
||||
<data name="Server.Copies.Confirm.Replace.Message.one" xml:space="preserve"><value>{0} foto va nel cestino quando la versione scelta è al suo posto.</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Confirm.Replace.Message.other" xml:space="preserve"><value>{0} foto vanno nel cestino quando la versione scelta è al suo posto.</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Confirm.LastCopy" xml:space="preserve"><value>Unica copia: {0}</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Confirm.Merge.Title" xml:space="preserve"><value>Unire le sequenze?</value></data>
|
||||
<data name="Server.Copies.Confirm.Merge.Message" xml:space="preserve"><value>{0} va nel cestino di {1} dopo la verifica di ogni foto in {2}.</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Confirm.Merge.TypedPrompt" xml:space="preserve"><value>Scrivi il numero di foto di {0} per confermare</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Confirm.Merge.OnlyHere.one" xml:space="preserve"><value>{0} foto esiste solo in {1}</value><comment>long</comment></data>
|
||||
<data name="Server.Copies.Confirm.Merge.OnlyHere.other" xml:space="preserve"><value>{0} foto esistono solo in {1}</value><comment>long</comment></data>
|
||||
<data name="Server.Error.TooMany" xml:space="preserve"><value>La richiesta chiedeva troppe foto insieme.</value><comment>long</comment></data>
|
||||
</root>
|
||||
@@ -281,4 +281,11 @@
|
||||
<data name="Settings.Archive.VideosPickTitle" xml:space="preserve"><value>Scegli la cartella video</value></data>
|
||||
<data name="Settings.Archive.VideosBrowse" xml:space="preserve"><value>Scegli…</value></data>
|
||||
<data name="Settings.Archive.VideosOpen" xml:space="preserve"><value>Apri cartella</value></data>
|
||||
<data name="Settings.Server.Copies" xml:space="preserve"><value>Corrispondenze</value></data>
|
||||
<data name="Settings.Server.CopyLinking" xml:space="preserve"><value>Collega corrispondenze</value></data>
|
||||
<data name="Settings.Server.CopyLinking.AskAlways" xml:space="preserve"><value>Chiedi sempre</value></data>
|
||||
<data name="Settings.Server.CopyLinking.WhenIdentical" xml:space="preserve"><value>Se identiche</value></data>
|
||||
<data name="Settings.Server.CopyLinking.WhenHalf" xml:space="preserve"><value>Metà in comune</value></data>
|
||||
<data name="Settings.Server.CopyPhotos" xml:space="preserve"><value>Foto da integrare</value></data>
|
||||
<data name="Settings.Server.CopyProjects" xml:space="preserve"><value>Progetti da integrare</value></data>
|
||||
</root>
|
||||
@@ -1141,4 +1141,106 @@
|
||||
<data name="Tooltips.Window.Maximize" xml:space="preserve"><value>Ingrandisci</value></data>
|
||||
<data name="Tooltips.Window.Minimize" xml:space="preserve"><value>Riduci a icona</value></data>
|
||||
<data name="Tooltips.Window.Restore" xml:space="preserve"><value>Ripristina</value></data>
|
||||
<data name="Tooltips.Server.Sync.Filter.FoundCopies" xml:space="preserve"><value>Sequenze che sembrano le stesse qui e sul server, o due volte su questo PC.</value></data>
|
||||
<data name="Tooltips.Server.Sync.Show" xml:space="preserve"><value>Mostra questo elenco.</value></data>
|
||||
<data name="Tooltips.Server.Sync.ShowSkipped" xml:space="preserve"><value>Mostra per prime in Solo locali le sequenze che Carica le locali ha saltato.</value></data>
|
||||
<data name="Tooltips.Server.Sync.State.CopyFound" xml:space="preserve"><value>Questa sequenza potrebbe essere anche su {0}. Confronta per decidere.</value></data>
|
||||
<data name="Tooltips.Server.Sync.State.Skipped" xml:space="preserve"><value>Carica le locali l'ha saltata: {0}.</value></data>
|
||||
<data name="Tooltips.Server.Sync.State.NotSent" xml:space="preserve"><value>Le foto non sono passate da sole: {0}.</value></data>
|
||||
<data name="Tooltips.Server.Sync.Skip.SuspectedCopy" xml:space="preserve"><value>potrebbe essere la stessa di una sequenza sul server</value></data>
|
||||
<data name="Tooltips.Server.Sync.Skip.KeptApart" xml:space="preserve"><value>l'hai tenuta separata da una corrispondenza</value></data>
|
||||
<data name="Tooltips.Server.Sync.Skip.ServerOriginals" xml:space="preserve"><value>viene da un server</value></data>
|
||||
<data name="Tooltips.Server.Sync.Skip.DeletedOnServer" xml:space="preserve"><value>il server ha eliminato la sua copia</value></data>
|
||||
<data name="Tooltips.Server.Sync.Skip.Busy" xml:space="preserve"><value>è in integrazione</value></data>
|
||||
<data name="Tooltips.Server.Sync.UploadAllSkipping.one" xml:space="preserve"><value>Carica le sequenze presenti solo qui; {0} che potrebbe essere già sul server resta da rivedere.</value></data>
|
||||
<data name="Tooltips.Server.Sync.UploadAllSkipping.other" xml:space="preserve"><value>Carica le sequenze presenti solo qui; {0} che potrebbero essere già sul server restano da rivedere.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Find" xml:space="preserve"><value>Cerca ora corrispondenze di queste sequenze su {0} e su questo PC.</value></data>
|
||||
<data name="Tooltips.Server.Copies.FindLocal" xml:space="preserve"><value>Cerca ora corrispondenze tra gli archivi di questo PC.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Compare" xml:space="preserve"><value>Mostra quali foto, dettagli e progetti differiscono tra le due sequenze.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Integrate" xml:space="preserve"><value>Completa entrambe le sequenze, risolvi una volta le differenze, poi tienile sincronizzate.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Merge" xml:space="preserve"><value>Unisce le due nella sequenza tenuta; l'altra va nel cestino dopo la verifica.</value></data>
|
||||
<data name="Tooltips.Server.Copies.KeepApart" xml:space="preserve"><value>Tiene le due sequenze separate e non chiede più. Carica le locali la salta.</value></data>
|
||||
<data name="Tooltips.Server.Copies.LinkOnly" xml:space="preserve"><value>Collega le due senza spostare foto; il prossimo confronto allinea i dettagli uguali.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Unlink" xml:space="preserve"><value>Smette di sincronizzare queste sequenze; non si elimina nulla.</value></data>
|
||||
<data name="Tooltips.Server.Copies.UndoUnlink" xml:space="preserve"><value>Collega di nuovo le due.</value></data>
|
||||
<data name="Tooltips.Server.Copies.UndoKeepApart" xml:space="preserve"><value>Mostra di nuovo questa corrispondenza.</value></data>
|
||||
<data name="Tooltips.Server.Copies.AskAgain" xml:space="preserve"><value>Mostra di nuovo questa coppia come corrispondenza.</value></data>
|
||||
<data name="Tooltips.Server.Copies.UploadAgain" xml:space="preserve"><value>Invia la sequenza di questo PC a {0} come nuova sequenza.</value></data>
|
||||
<data name="Tooltips.Server.Copies.KeepHere" xml:space="preserve"><value>Tiene la sequenza di questo PC e non chiede più; Carica le locali la salta.</value></data>
|
||||
<data name="Tooltips.Server.Copies.ToTrash" xml:space="preserve"><value>Sposta queste foto nel cestino dell'archivio dopo un piano da confermare.</value></data>
|
||||
<data name="Tooltips.Server.Copies.ToTrashSequence" xml:space="preserve"><value>Sposta la sequenza di questo PC nel cestino dell'archivio; potrebbe essere l'unica copia.</value></data>
|
||||
<data name="Tooltips.Server.Copies.DeleteOnServer" xml:space="preserve"><value>Sposta queste foto nel cestino del server dopo un piano da confermare.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Review" xml:space="preserve"><value>Apre il confronto sulle foto eliminate dall'altra parte.</value></data>
|
||||
<data name="Tooltips.Server.Copies.ReviewFound" xml:space="preserve"><value>Apre l'elenco delle corrispondenze trovate.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Drop" xml:space="preserve"><value>Sposta questa versione nel cestino di ogni lato che la tiene.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Choose" xml:space="preserve"><value>Vai alle scelte ancora mancanti.</value></data>
|
||||
<data name="Tooltips.Server.Copies.State.Candidate" xml:space="preserve"><value>Il {0} % delle foto è in comune. Confronta per decidere.</value></data>
|
||||
<data name="Tooltips.Server.Copies.State.KeptApart" xml:space="preserve"><value>Hai scelto di tenerle separate il {0}.</value></data>
|
||||
<data name="Tooltips.Server.Copies.State.Linked" xml:space="preserve"><value>Collegate: la sincronizzazione le confronta; le foto si spostano con Carica e Scarica.</value></data>
|
||||
<data name="Tooltips.Server.Copies.State.Integrating" xml:space="preserve"><value>In integrazione; il lavoro mostra ogni passo.</value></data>
|
||||
<data name="Tooltips.Server.Copies.State.Integrated" xml:space="preserve"><value>Le foto nuove passano da sole nei due sensi; le eliminazioni aspettano te.</value></data>
|
||||
<data name="Tooltips.Server.Copies.State.RemoteGone" xml:space="preserve"><value>Il server ha eliminato la sua copia; la sequenza di questo PC è intatta.</value></data>
|
||||
<data name="Tooltips.Server.Copies.State.KeptHere" xml:space="preserve"><value>Hai tenuto la sequenza di questo PC dopo che il server ha eliminato la sua copia.</value></data>
|
||||
<data name="Tooltips.Server.Copies.State.DeletedThere.one" xml:space="preserve"><value>{0} foto è stata eliminata dall'altra parte; resta qui finché non scegli.</value></data>
|
||||
<data name="Tooltips.Server.Copies.State.DeletedThere.other" xml:space="preserve"><value>{0} foto sono state eliminate dall'altra parte; restano qui finché non scegli.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Class.Same" xml:space="preserve"><value>Gli stessi file sui due lati, per SHA-256.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Class.SameUnhashed" xml:space="preserve"><value>Stessa dimensione e ora di scatto; un lato non è ancora verificato. Un'unione le controlla prima per hash.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Class.OnlyHere" xml:space="preserve"><value>Foto che ha solo questo lato; Integra le copia sull'altro.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Class.OnlyThere" xml:space="preserve"><value>Foto che ha solo l'altro lato; Integra le copia qui.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Class.Differs" xml:space="preserve"><value>Stesso nome e ora di scatto, file diversi. Unione tiene entrambe le versioni.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Class.Converted" xml:space="preserve"><value>La stessa foto in un'altra codifica; conta come una.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Class.DeletedHere" xml:space="preserve"><value>Eliminate da questo lato, ancora sull'altro. Mai riportate.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Class.DeletedThere" xml:space="preserve"><value>Eliminate dall'altro lato, ancora qui. Nulla si elimina senza conferma.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Class.Versions" xml:space="preserve"><value>Due file della stessa ora di scatto; quello dell'altro lato è escluso in Main.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Policy" xml:space="preserve"><value>La scelta delle foto per questa volta; Impostazioni › Server dà quella predefinita.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Policy.Union" xml:space="preserve"><value>Ogni foto delle due sequenze finisce in entrambe; quelle diverse tengono entrambe le versioni.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Policy.ChoosePerPhoto" xml:space="preserve"><value>Scegli tu quali foto portare; nulla è preselezionato.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Policy.ThisPcWins" xml:space="preserve"><value>Le foto presenti su un solo lato vanno su entrambi; per le foto diverse la versione di questo PC sostituisce quella del server, che va nel cestino.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Policy.OtherWins" xml:space="preserve"><value>Le foto presenti su un solo lato vanno su entrambi; per le foto diverse la versione del server sostituisce quella di questo PC, che va nel cestino.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Policy.KeptWins" xml:space="preserve"><value>Ogni foto dell'altra entra in quella tenuta; per le foto diverse resta la versione tenuta.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Policy.OtherCopyWins" xml:space="preserve"><value>Ogni foto dell'altra entra in quella tenuta; per le foto diverse la versione dell'altra sostituisce quella tenuta, che va nel cestino.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Bring" xml:space="preserve"><value>Copia questa foto dall'altra parte.</value></data>
|
||||
<data name="Tooltips.Server.Copies.BringAll" xml:space="preserve"><value>Seleziona tutte le foto di questo elenco.</value></data>
|
||||
<data name="Tooltips.Server.Copies.BringNone" xml:space="preserve"><value>Deseleziona tutte le foto di questo elenco.</value></data>
|
||||
<data name="Tooltips.Server.Copies.AllBoth" xml:space="preserve"><value>Tiene entrambe le versioni di ogni foto diversa.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Version" xml:space="preserve"><value>Cosa fare di questi due file diversi della stessa ora di scatto.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Detail" xml:space="preserve"><value>Il valore che prendono entrambe le sequenze.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Detail.All" xml:space="preserve"><value>Prende il valore di questo lato per ogni differenza.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Projects.CopyAcross" xml:space="preserve"><value>Gli altri progetti di ogni lato compaiono nell'altra sede con la loro storia, rinominati se il nome è preso.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Projects.Leave" xml:space="preserve"><value>Gli altri progetti restano dove sono; Modifica segna le due copie di lavoro come gemelle.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Projects.MergeAlways" xml:space="preserve"><value>Un'unione copia sempre i progetti dell'altra: la sua sede va nel cestino.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Projects.Main" xml:space="preserve"><value>Main segue i dettagli che scegli.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Plan.Free" xml:space="preserve"><value>Spazio libero dove le foto vengono archiviate; il cestino libera spazio solo quando è svuotato.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Plan.Quota" xml:space="preserve"><value>Quanto il tuo account può ancora archiviare sul server.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Plan.LastCopies" xml:space="preserve"><value>Queste foto non esistono altrove; vanno nel cestino e si possono ripristinare da lì.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Plan.LeftOut" xml:space="preserve"><value>Le foto escluse restano su un lato, quindi le foto nuove si spostano solo con Carica e Scarica.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Plan.ServerUsesOurs" xml:space="preserve"><value>Il Main del server passa alla versione di questo PC di ogni foto diversa; i suoi video di quelle foto cambiano.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Plan.SessionKeys" xml:space="preserve"><value>Le importazioni future della stessa scheda o cartella entrano nella sequenza tenuta. Restano le chiavi già usate: {0}.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Plan.Relink" xml:space="preserve"><value>Il collegamento passa alla sequenza tenuta; il prossimo confronto allinea i dettagli uguali o mostra un conflitto.</value></data>
|
||||
<data name="Tooltips.Server.Copies.KeptCopy" xml:space="preserve"><value>La sequenza che resta; le foto dell'altra vi si uniscono.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Cancel" xml:space="preserve"><value>Chiude senza cambiare nulla.</value></data>
|
||||
<data name="Tooltips.Server.Copies.LinkTaken" xml:space="preserve"><value>Una delle due sequenze è già collegata a un'altra sequenza di {0}.</value></data>
|
||||
<data name="Tooltips.Server.Copies.NeedsNewerServer" xml:space="preserve"><value>Questo server va aggiornato per integrare le sequenze.</value></data>
|
||||
<data name="Tooltips.Server.Copies.SignIn" xml:space="preserve"><value>Accedi a {0} per agire su questa coppia.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Confirm.Safe" xml:space="preserve"><value>Chiude senza cambiare nulla.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Confirm.Replace.Action" xml:space="preserve"><value>Integra, poi sposta nel cestino le versioni sostituite.</value></data>
|
||||
<data name="Tooltips.Server.Copies.Confirm.Merge.Action" xml:space="preserve"><value>Unisce, poi sposta l'altra sequenza nel cestino dopo la verifica.</value></data>
|
||||
<data name="Tooltips.Jobs.OpenMatch" xml:space="preserve"><value>Mostra le sequenze su cui ha lavorato questo lavoro.</value></data>
|
||||
<data name="Tooltips.Library.Status.CopyFound" xml:space="preserve"><value>Anche su {0} · {1} % in comune.</value></data>
|
||||
<data name="Tooltips.Library.Status.CopyFoundLocal" xml:space="preserve"><value>Anche in {0}.</value></data>
|
||||
<data name="Tooltips.Library.Status.DeletedThere" xml:space="preserve"><value>Foto di questa sequenza sono state eliminate su {0}; restano qui finché non scegli.</value></data>
|
||||
<data name="Tooltips.Library.Compare" xml:space="preserve"><value>Confronta questa sequenza con la sua corrispondenza.</value></data>
|
||||
<data name="Tooltips.Editor.Picker.Twin" xml:space="preserve"><value>Anche in {0}: {1}.</value></data>
|
||||
<data name="Tooltips.Settings.CopyLinking" xml:space="preserve"><value>Cosa fa Chronos con due copie della stessa sequenza che trova. Le sequenze collegate restano sincronizzate.</value></data>
|
||||
<data name="Tooltips.Settings.CopyLinking.AskAlways" xml:space="preserve"><value>Mostra ogni corrispondenza; nulla si collega finché non scegli.</value></data>
|
||||
<data name="Tooltips.Settings.CopyLinking.WhenIdentical" xml:space="preserve"><value>Collega da sole le sequenze con le stesse identiche foto; chiede per le altre.</value></data>
|
||||
<data name="Tooltips.Settings.CopyLinking.WhenHalf" xml:space="preserve"><value>Collega le sequenze che iniziano nello stesso secondo con la stessa fotocamera e condividono almeno metà delle foto, come Chronos 1.1.</value></data>
|
||||
<data name="Tooltips.Settings.CopyPhotos" xml:space="preserve"><value>La scelta delle foto da cui parte Integra; puoi cambiarla ogni volta.</value></data>
|
||||
<data name="Tooltips.Settings.CopyPhotos.Union" xml:space="preserve"><value>Ogni foto delle due sequenze finisce in entrambe; quelle diverse tengono entrambe le versioni.</value></data>
|
||||
<data name="Tooltips.Settings.CopyPhotos.ChoosePerPhoto" xml:space="preserve"><value>Scegli tu quali foto portare; nulla è preselezionato.</value></data>
|
||||
<data name="Tooltips.Settings.CopyPhotos.ThisPcWins" xml:space="preserve"><value>Le foto presenti su un solo lato vanno su entrambi; per le foto diverse la versione di questo PC sostituisce quella del server, che va nel cestino.</value></data>
|
||||
<data name="Tooltips.Settings.CopyPhotos.OtherWins" xml:space="preserve"><value>Le foto presenti su un solo lato vanno su entrambi; per le foto diverse la versione del server sostituisce quella di questo PC, che va nel cestino.</value></data>
|
||||
<data name="Tooltips.Settings.CopyProjects" xml:space="preserve"><value>Se Integra copia gli altri progetti nell'altra sede, rinominati se il nome è preso.</value></data>
|
||||
<data name="Tooltips.Settings.CopyProjects.CopyAcross" xml:space="preserve"><value>Gli altri progetti di ogni lato compaiono nell'altra sede con la loro storia, rinominati se il nome è preso.</value></data>
|
||||
<data name="Tooltips.Settings.CopyProjects.Leave" xml:space="preserve"><value>Gli altri progetti restano dove sono; Modifica segna le due copie di lavoro come gemelle.</value></data>
|
||||
</root>
|
||||
@@ -9,6 +9,7 @@ using Chronos.Core.IO;
|
||||
using Chronos.Core.Naming;
|
||||
using Chronos.Core.Project;
|
||||
using Chronos.Data.Archiving;
|
||||
using Chronos.Data.Copies;
|
||||
using Chronos.Data.Repositories;
|
||||
using Chronos.Data.Sync;
|
||||
using Chronos.Ui.Theming;
|
||||
@@ -341,6 +342,15 @@ public sealed class AppSettings
|
||||
/// <summary>Pause transfers with a server (uploads, sync downloads, workspace copies and renders sent) while Windows reports the connection as metered (Server.html).</summary>
|
||||
public bool PauseUploadsOnMetered { get; set; }
|
||||
|
||||
/// <summary>Settings › Server › Link matches (owner review 6, Q1): what Chronos does with two copies of one sequence it finds.</summary>
|
||||
public CopyLinking CopyLinking { get; set; } = CopyLinking.AskAlways;
|
||||
|
||||
/// <summary>Settings › Server › Integrate photos (owner review 6, Q3): the photo choice an Integrate starts from.</summary>
|
||||
public CopyPhotoPolicy CopyPhotos { get; set; } = CopyPhotoPolicy.Union;
|
||||
|
||||
/// <summary>Settings › Server › Integrate projects (owner review 6, Q5): the projects choice an Integrate starts from.</summary>
|
||||
public CopyProjects CopyProjects { get; set; } = CopyProjects.CopyAcross;
|
||||
|
||||
// ---- Jobs ----
|
||||
/// <summary>
|
||||
/// The priority queue (owner review 1): a job of a higher level makes the running one of a lower level yield, and that
|
||||
|
||||
@@ -41,7 +41,7 @@ public static class JobNotices
|
||||
private static bool Announces(JobKind kind) =>
|
||||
kind is JobKind.Render or JobKind.DeepAnalyse or JobKind.Verify or JobKind.Rebuild or JobKind.Maintenance or JobKind.UploadCommit
|
||||
or JobKind.Move or JobKind.Adopt or JobKind.EmptyTrash or JobKind.Convert or JobKind.WorkspaceRender or JobKind.WorkspaceSend
|
||||
or JobKind.WorkspaceMove or JobKind.VideoCopy;
|
||||
or JobKind.WorkspaceMove or JobKind.VideoCopy or JobKind.Integrate or JobKind.MergeSequences;
|
||||
|
||||
/// <summary>
|
||||
/// Work that keeps the index and its previews current: the next run repeats it, the Archive screen shows what is missing.
|
||||
|
||||
@@ -8,6 +8,7 @@ using Chronos.Core.Localization;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Core.Project;
|
||||
using Chronos.Data;
|
||||
using Chronos.Data.Copies;
|
||||
using Chronos.Data.Homes;
|
||||
using Chronos.Data.Jobs;
|
||||
using Chronos.Data.Projects;
|
||||
@@ -47,13 +48,15 @@ public sealed class SyncHost(AppServices services) : ISyncConnector, IAsyncDispo
|
||||
|
||||
/// <summary>Jobs that write into the workspace or the servers' homes in the cache: the move of the folders to a server's id waits for them.</summary>
|
||||
private static readonly JobKind[] RekeyHeldBy =
|
||||
[JobKind.WorkspaceCopy, JobKind.WorkspaceRender, JobKind.WorkspaceSend, JobKind.WorkspaceMove, JobKind.Download, JobKind.UploadCommit, JobKind.VideoCopy];
|
||||
[JobKind.WorkspaceCopy, JobKind.WorkspaceRender, JobKind.WorkspaceSend, JobKind.WorkspaceMove, JobKind.Download, JobKind.UploadCommit, JobKind.VideoCopy,
|
||||
JobKind.Integrate, JobKind.MergeSequences];
|
||||
|
||||
private readonly Lock _gate = new();
|
||||
private Task _switch = Task.CompletedTask;
|
||||
private Credentials? _credentials;
|
||||
private Running? _running;
|
||||
private JobEngine? _renders;
|
||||
private ICopyEngine? _copies;
|
||||
|
||||
/// <summary>The alias table of <see cref="AppSettings.KnownServers"/>, made again whenever a sign-in records a server.</summary>
|
||||
private ServerIdentity _identity = services.Settings.KnownIdentity();
|
||||
@@ -107,7 +110,25 @@ public sealed class SyncHost(AppServices services) : ISyncConnector, IAsyncDispo
|
||||
}
|
||||
|
||||
/// <summary>The options, and whether the account may change server sequences (without it this PC's edits are not sent).</summary>
|
||||
public SyncPolicy Policy => new(services.Settings.SyncSettingsAutomatically, services.Settings.KeepProxiesOffline, Allows(Permissions.Edit));
|
||||
public SyncPolicy Policy => new(services.Settings.SyncSettingsAutomatically, services.Settings.KeepProxiesOffline, Allows(Permissions.Edit),
|
||||
services.Settings.CopyLinking);
|
||||
|
||||
/// <summary>
|
||||
/// The matches engine (owner review 6, #73): found copies here and on the server, compare, integrate, merge; null until
|
||||
/// the index is open. Setting it raises <see cref="CopiesChanged"/>.
|
||||
/// </summary>
|
||||
public ICopyEngine? Copies
|
||||
{
|
||||
get => Volatile.Read(ref _copies);
|
||||
internal set
|
||||
{
|
||||
if (ReferenceEquals(Interlocked.Exchange(ref _copies, value), value)) return;
|
||||
CopiesChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary><see cref="Copies"/> was set or cleared (any thread).</summary>
|
||||
public event Action? CopiesChanged;
|
||||
|
||||
/// <summary>The signed-in account may send files (originals, renders) to the server.</summary>
|
||||
public bool CanUpload => Allows(Permissions.Upload);
|
||||
|
||||
@@ -129,6 +129,19 @@ public enum JobKind
|
||||
/// its name, the render itself never touched; on the desktop a server-only render is downloaded into it; stored as 24.
|
||||
/// </summary>
|
||||
VideoCopy = 24,
|
||||
|
||||
/// <summary>
|
||||
/// Integrates a local sequence with its match on a server (owner review 6, #73): each side receives the photos it lacks,
|
||||
/// the details are settled once as chosen, other projects are copied across, then the two stay linked; journaled,
|
||||
/// resumable and hash-verified; stored as 25.
|
||||
/// </summary>
|
||||
Integrate = 25,
|
||||
|
||||
/// <summary>
|
||||
/// Merges two local copies of one time-lapse into the kept sequence (owner review 6, #73): every photo verified in it,
|
||||
/// then the other sequence goes to the archive trash; journaled and resumable; stored as 26.
|
||||
/// </summary>
|
||||
MergeSequences = 26,
|
||||
}
|
||||
|
||||
/// <summary>Why a photo left a sequence (its tombstone, owner review 2, R6); stored as a number.</summary>
|
||||
|
||||
@@ -31,6 +31,9 @@ public enum JobStep
|
||||
Maintenance,
|
||||
FollowUps,
|
||||
Process,
|
||||
Details,
|
||||
Projects,
|
||||
Trash,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -145,9 +145,11 @@ public sealed partial class FrameTrash
|
||||
/// The dry run: the frames of <paramref name="frameIds"/> that go and their size, or why they cannot go. With
|
||||
/// <paramref name="expectedFramesVersion"/>, frames that changed since the caller read that version block the plan.
|
||||
/// </summary>
|
||||
/// <param name="exceptJob">The job asking, when the step runs inside a job that targets the sequence (an Integrate or a
|
||||
/// merge, owner review 6): its own hold does not make the sequence busy.</param>
|
||||
/// <exception cref="ArgumentException">The sequence is not in the index, or no frame is named.</exception>
|
||||
public async Task<FrameDeletePlan> PlanDeleteAsync(Guid sequenceId, IReadOnlyList<Guid> frameIds, int? expectedFramesVersion = null,
|
||||
CancellationToken cancellationToken = default)
|
||||
CancellationToken cancellationToken = default, Guid? exceptJob = null)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(frameIds);
|
||||
if (frameIds.Count == 0) throw new ArgumentException("No frame is named.", nameof(frameIds));
|
||||
@@ -162,7 +164,7 @@ public sealed partial class FrameTrash
|
||||
var paths = new ArchivePaths(archive.RootPath);
|
||||
var online = ArchiveVolume.Probe(paths) == ArchiveAvailability.Online;
|
||||
if (!online) blocked.Add(FrameDeleteBlock.Offline);
|
||||
var busy = await _trash.BusyAsync(cancellationToken).ConfigureAwait(false);
|
||||
var busy = await _trash.BusyAsync(exceptJob, cancellationToken).ConfigureAwait(false);
|
||||
if (busy.Contains(sequence.Id) || busy.Contains(sequence.ArchiveId)) blocked.Add(FrameDeleteBlock.Busy);
|
||||
if (frames.Count != wanted.Count || (expectedFramesVersion is { } expected && expected != sequence.FramesVersion)) blocked.Add(FrameDeleteBlock.FramesChanged);
|
||||
if (frames.Count > 0 && frames.Count == all.Count) blocked.Add(FrameDeleteBlock.WouldEmpty);
|
||||
@@ -210,16 +212,18 @@ public sealed partial class FrameTrash
|
||||
/// written the deletion stands: an index that cannot follow (logged) is resynced by the next scan.
|
||||
/// </summary>
|
||||
/// <param name="deletedBy">Who asked (user name or client), kept in the trash record.</param>
|
||||
/// <param name="exceptJob">The job asking, when it targets the sequence itself (see <see cref="PlanDeleteAsync"/>).</param>
|
||||
/// <exception cref="StaleDeletePlanException">The plan is blocked, or the sequence changed since it was made; nothing moved.</exception>
|
||||
/// <exception cref="ArchiveOfflineException">The archive went offline; nothing moved.</exception>
|
||||
/// <exception cref="IOException">A file is open elsewhere, or the sidecar could not be written; nothing moved.</exception>
|
||||
public async Task<FrameDeleteResult> DeleteAsync(FrameDeletePlan plan, string? deletedBy = null, JobEngine? followUps = null,
|
||||
CancellationToken cancellationToken = default)
|
||||
CancellationToken cancellationToken = default, Guid? exceptJob = null)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(plan);
|
||||
var id = plan.Sequence.Id;
|
||||
if (!plan.CanDelete) throw new StaleDeletePlanException(id);
|
||||
var revised = await PlanDeleteAsync(id, [.. plan.Frames.Select(f => f.Id)], plan.Sequence.FramesVersion, cancellationToken).ConfigureAwait(false);
|
||||
var revised = await PlanDeleteAsync(id, [.. plan.Frames.Select(f => f.Id)], plan.Sequence.FramesVersion, cancellationToken, exceptJob)
|
||||
.ConfigureAwait(false);
|
||||
var archive = await ArchiveOfAsync(revised.Sequence, cancellationToken).ConfigureAwait(false);
|
||||
var paths = new ArchivePaths(archive.RootPath);
|
||||
// Offline since the plan: said as such (ArchiveOfflineException), not as a stale plan.
|
||||
|
||||
@@ -148,10 +148,13 @@ public sealed partial class SequenceTrash
|
||||
|
||||
/// <summary>The dry run: for each sequence, where its folder goes and how many files and bytes it holds, or why it cannot go.</summary>
|
||||
/// <param name="progress">Sequences checked so far.</param>
|
||||
/// <param name="exceptJob">The job asking, when the step runs inside a job that targets the sequences (a merge, owner
|
||||
/// review 6): its own hold does not make them busy.</param>
|
||||
/// <exception cref="ArgumentException">A sequence is not in the index.</exception>
|
||||
public async Task<DeletePlan> PlanAsync(IReadOnlyList<Guid> sequenceIds, IProgress<int>? progress = null, CancellationToken cancellationToken = default)
|
||||
public async Task<DeletePlan> PlanAsync(IReadOnlyList<Guid> sequenceIds, IProgress<int>? progress = null, CancellationToken cancellationToken = default,
|
||||
Guid? exceptJob = null)
|
||||
{
|
||||
var busy = await BusyAsync(cancellationToken).ConfigureAwait(false);
|
||||
var busy = await BusyAsync(exceptJob, cancellationToken).ConfigureAwait(false);
|
||||
var archives = new Dictionary<Guid, ArchiveContext?>();
|
||||
var steps = new List<DeleteStep>();
|
||||
var blocked = new List<BlockedDelete>();
|
||||
@@ -197,16 +200,24 @@ public sealed partial class SequenceTrash
|
||||
/// busy; sequences before it are in the trash.</exception>
|
||||
/// <exception cref="InvalidDataException">The sidecar of a sequence with an interrupted journal is damaged; sequences
|
||||
/// before it are in the trash.</exception>
|
||||
/// <param name="exceptJob">The job asking, when it targets the sequences itself (see <see cref="PlanAsync"/>).</param>
|
||||
/// <param name="expectedFramesVersions">
|
||||
/// The frames version each sequence must still have, checked under the sequence's lease just before its folder moves (a
|
||||
/// merge: a photo added to the dropped sequence meanwhile refuses that step with <see cref="StaleDeletePlanException"/>,
|
||||
/// nothing of it moved). Sequences it does not name are not checked.
|
||||
/// </param>
|
||||
public async Task<IReadOnlyList<TrashEntry>> DeleteAsync(DeletePlan plan, string? deletedBy = null, IProgress<int>? progress = null,
|
||||
CancellationToken cancellationToken = default)
|
||||
CancellationToken cancellationToken = default, Guid? exceptJob = null, IReadOnlyDictionary<Guid, int>? expectedFramesVersions = null)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(plan);
|
||||
await RevalidateAsync(plan, cancellationToken).ConfigureAwait(false);
|
||||
await RevalidateAsync(plan, exceptJob, cancellationToken).ConfigureAwait(false);
|
||||
var entries = new List<TrashEntry>(plan.Steps.Count);
|
||||
for (var i = 0; i < plan.Steps.Count; i++)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
if (await DeleteOneAsync(plan.Steps[i], deletedBy, cancellationToken).ConfigureAwait(false) is { } entry) entries.Add(entry);
|
||||
var step = plan.Steps[i];
|
||||
int? expected = expectedFramesVersions is not null && expectedFramesVersions.TryGetValue(step.Sequence.Id, out var version) ? version : null;
|
||||
if (await DeleteOneAsync(step, deletedBy, expected, cancellationToken).ConfigureAwait(false) is { } entry) entries.Add(entry);
|
||||
progress?.Report(i + 1);
|
||||
}
|
||||
return entries;
|
||||
@@ -350,9 +361,9 @@ public sealed partial class SequenceTrash
|
||||
}
|
||||
|
||||
/// <summary>Checks the plan again just before anything moves, without measuring the folders again; any change refuses it whole.</summary>
|
||||
private async Task RevalidateAsync(DeletePlan plan, CancellationToken cancellationToken)
|
||||
private async Task RevalidateAsync(DeletePlan plan, Guid? exceptJob, CancellationToken cancellationToken)
|
||||
{
|
||||
var busy = await BusyAsync(cancellationToken).ConfigureAwait(false);
|
||||
var busy = await BusyAsync(exceptJob, cancellationToken).ConfigureAwait(false);
|
||||
var archives = new Dictionary<Guid, ArchiveContext?>();
|
||||
foreach (var step in plan.Steps)
|
||||
{
|
||||
@@ -370,7 +381,7 @@ public sealed partial class SequenceTrash
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<TrashEntry?> DeleteOneAsync(DeleteStep step, string? deletedBy, CancellationToken cancellationToken)
|
||||
private async Task<TrashEntry?> DeleteOneAsync(DeleteStep step, string? deletedBy, int? expectedFramesVersion, CancellationToken cancellationToken)
|
||||
{
|
||||
var sequence = step.Sequence;
|
||||
var archive = await _db.Archives.GetAsync(sequence.ArchiveId, cancellationToken).ConfigureAwait(false)
|
||||
@@ -383,6 +394,7 @@ public sealed partial class SequenceTrash
|
||||
{
|
||||
var row = await _db.Sequences.GetAsync(sequence.Id, cancellationToken).ConfigureAwait(false);
|
||||
if (row is null || row.Folder != sequence.Folder) throw new StaleDeletePlanException(sequence.Id);
|
||||
if (expectedFramesVersion is { } expected && row.FramesVersion != expected) throw new StaleDeletePlanException(sequence.Id);
|
||||
if (step.TrashFolder is null)
|
||||
{
|
||||
await RemoveRowsAsync(archive.Id, row, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Chronos.Data.Copies;
|
||||
|
||||
/// <summary>
|
||||
/// The parameters of a <see cref="Core.Model.JobKind.Integrate"/> job: the pair, the choices the job plans again from, the
|
||||
/// fingerprint of the plan the user confirmed, and whether new photos move by themselves once it is done.
|
||||
/// </summary>
|
||||
public sealed record IntegrateJobParameters(Guid CopyId, string Server, Guid LocalId, Guid RemoteId, IntegrateChoices Choices,
|
||||
string Fingerprint, bool AutoPhotos)
|
||||
{
|
||||
public string ToJson() => JsonSerializer.Serialize(this, CopyJobJson.Default.IntegrateJobParameters);
|
||||
|
||||
/// <summary>The parameters in <paramref name="json"/>; null when it holds none.</summary>
|
||||
public static IntegrateJobParameters? Read(string? json)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(json)) return null;
|
||||
try
|
||||
{
|
||||
return JsonSerializer.Deserialize(json, CopyJobJson.Default.IntegrateJobParameters) is { Server.Length: > 0, Choices: not null } p ? p : null;
|
||||
}
|
||||
catch (JsonException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The parameters of a <see cref="Core.Model.JobKind.MergeSequences"/> job: the pair, the sequence kept and the one that goes
|
||||
/// to the trash, the choices the job plans again from, and the fingerprint of the plan the user confirmed.
|
||||
/// </summary>
|
||||
public sealed record MergeJobParameters(Guid CopyId, Guid KeepId, Guid DropId, MergeChoices Choices, string Fingerprint)
|
||||
{
|
||||
public string ToJson() => JsonSerializer.Serialize(this, CopyJobJson.Default.MergeJobParameters);
|
||||
|
||||
/// <summary>The parameters in <paramref name="json"/>; null when it holds none.</summary>
|
||||
public static MergeJobParameters? Read(string? json)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(json)) return null;
|
||||
try
|
||||
{
|
||||
return JsonSerializer.Deserialize(json, CopyJobJson.Default.MergeJobParameters) is { Choices: not null } p ? p : null;
|
||||
}
|
||||
catch (JsonException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, UseStringEnumConverter = true,
|
||||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
[JsonSerializable(typeof(IntegrateJobParameters))]
|
||||
[JsonSerializable(typeof(MergeJobParameters))]
|
||||
internal sealed partial class CopyJobJson : JsonSerializerContext;
|
||||
@@ -0,0 +1,209 @@
|
||||
namespace Chronos.Data.Copies;
|
||||
|
||||
/// <summary>What a found copy pairs (owner review 6, #73); stored as a number.</summary>
|
||||
public enum CopyKind
|
||||
{
|
||||
/// <summary>A local sequence and a sequence of a server.</summary>
|
||||
LocalServer = 0,
|
||||
|
||||
/// <summary>Two local sequences of this index (stored ordered, the smaller id first).</summary>
|
||||
LocalLocal = 1,
|
||||
}
|
||||
|
||||
/// <summary>Strongest evidence the pair was found by (stored as a number; never reordered).</summary>
|
||||
public enum CopyEvidence
|
||||
{
|
||||
Link = 0,
|
||||
SessionKey = 1,
|
||||
Hashes = 2,
|
||||
SizeAndTime = 3,
|
||||
Hints = 4,
|
||||
}
|
||||
|
||||
/// <summary>Where a found copy stands (stored as a number; never reordered).</summary>
|
||||
public enum CopyState
|
||||
{
|
||||
/// <summary>Found and not answered: the user is asked.</summary>
|
||||
Candidate = 0,
|
||||
|
||||
/// <summary>The user kept the two apart; asked again only by a large later change.</summary>
|
||||
KeptApart = 1,
|
||||
|
||||
/// <summary>Linked: sync compares the two; photos move on Upload and Download.</summary>
|
||||
Linked = 2,
|
||||
|
||||
/// <summary>An Integrate or Merge job works on the pair.</summary>
|
||||
Integrating = 3,
|
||||
|
||||
/// <summary>Integrated: linked, and new photos may move by themselves (<see cref="FoundCopy.AutoPhotos"/>).</summary>
|
||||
Integrated = 4,
|
||||
}
|
||||
|
||||
/// <summary>Settings › Server › Link matches (owner review 6, Q1).</summary>
|
||||
public enum CopyLinking
|
||||
{
|
||||
AskAlways = 0,
|
||||
WhenIdentical = 1,
|
||||
WhenHalfShared = 2,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Settings › Server › Integrate photos and the dialog's photo choice (owner review 6, Q3). ThisPcWins / OtherWins decide
|
||||
/// the Different class only; for a local pair ThisPcWins = the kept sequence wins.
|
||||
/// </summary>
|
||||
public enum CopyPhotoPolicy
|
||||
{
|
||||
Union = 0,
|
||||
ChoosePerPhoto = 1,
|
||||
ThisPcWins = 2,
|
||||
OtherWins = 3,
|
||||
}
|
||||
|
||||
/// <summary>Settings › Server › Integrate projects and the dialog's projects choice (owner review 6, Q5). A merge always copies across.</summary>
|
||||
public enum CopyProjects
|
||||
{
|
||||
CopyAcross = 0,
|
||||
Leave = 1,
|
||||
}
|
||||
|
||||
/// <summary>A side of a pair: this PC's copy (the kept one of a merge) or the other one.</summary>
|
||||
public enum CopySide
|
||||
{
|
||||
ThisPc = 0,
|
||||
Other = 1,
|
||||
}
|
||||
|
||||
/// <summary>What detection does with a pair that has no answer yet (<c>CopyRules.Decide</c>).</summary>
|
||||
public enum CopyDecision
|
||||
{
|
||||
/// <summary>Not a pair: nothing is kept.</summary>
|
||||
None = 0,
|
||||
|
||||
/// <summary>Shown as a match found; nothing is linked until the user chooses.</summary>
|
||||
Ask = 1,
|
||||
|
||||
/// <summary>Linked by itself, as the Link matches setting allows.</summary>
|
||||
Link = 2,
|
||||
}
|
||||
|
||||
/// <summary>The counts of an exact comparison (design §4); ratios in per mille.</summary>
|
||||
public sealed record CopyScore(int Shared, int SharedUnhashed, int SharedRemoved, int OnlyHere, int OnlyThere, int Differs,
|
||||
int DeletedHere, int DeletedThere, int Versions, int LocalPhotos, int OtherPhotos, int Containment, int Overlap, int Hints)
|
||||
{
|
||||
public static CopyScore None { get; } = new(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Exactly the same photos: nothing only on one side, nothing different, nothing deleted on one side only, and something
|
||||
/// shared (owner Q1 "exactly the same photos").
|
||||
/// </summary>
|
||||
public bool Identical => OnlyHere == 0 && OnlyThere == 0 && Differs == 0 && DeletedHere == 0 && DeletedThere == 0
|
||||
&& Shared + SharedUnhashed > 0;
|
||||
|
||||
/// <summary>Every shared photo is known by SHA-256 on both sides.</summary>
|
||||
public bool ByHash => SharedUnhashed == 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Two copies of one time-lapse whose ids differ (a row of <c>found_copies</c>): a local sequence and a sequence of a server,
|
||||
/// or two local sequences, with the evidence, the scores of the last comparison, the user's answer and the pair's policy.
|
||||
/// </summary>
|
||||
public sealed record FoundCopy
|
||||
{
|
||||
public required Guid Id { get; init; }
|
||||
|
||||
public required CopyKind Kind { get; init; }
|
||||
|
||||
/// <summary>The local sequence; for a local pair the smaller id of the two (<see cref="FoundCopyStore.Order"/>).</summary>
|
||||
public required Guid LocalId { get; init; }
|
||||
|
||||
/// <summary>The server's key (kind 0).</summary>
|
||||
public string? Server { get; init; }
|
||||
|
||||
/// <summary>The server's sequence (kind 0).</summary>
|
||||
public Guid? RemoteId { get; init; }
|
||||
|
||||
/// <summary>The other local sequence (kind 1).</summary>
|
||||
public Guid? OtherId { get; init; }
|
||||
|
||||
public required CopyEvidence Evidence { get; init; }
|
||||
|
||||
public CopyState State { get; init; }
|
||||
|
||||
/// <summary>The state before Integrating (Candidate, Linked): what a cancelled or failed job returns the pair to.</summary>
|
||||
public CopyState? PreviousState { get; init; }
|
||||
|
||||
public CopyScore Score { get; init; } = CopyScore.None;
|
||||
|
||||
public int LocalFramesVersion { get; init; }
|
||||
|
||||
public int OtherFramesVersion { get; init; }
|
||||
|
||||
public required string Fingerprint { get; init; }
|
||||
|
||||
public string? AnsweredFingerprint { get; init; }
|
||||
|
||||
public int? AnsweredShared { get; init; }
|
||||
|
||||
/// <summary>New photos move both ways by themselves (an integrated pair whose plan left nothing out).</summary>
|
||||
public bool AutoPhotos { get; init; }
|
||||
|
||||
/// <summary>The Integrate or Merge job of an Integrating pair.</summary>
|
||||
public Guid? JobId { get; init; }
|
||||
|
||||
public DateTimeOffset? RemoteGoneAt { get; init; }
|
||||
|
||||
/// <summary>404 answers for the remote side, by the server with the link key's own id, on distinct refreshes (design §6.3).</summary>
|
||||
public int RemoteGoneHits { get; init; }
|
||||
|
||||
public DateTimeOffset FoundAt { get; init; }
|
||||
|
||||
public DateTimeOffset UpdatedAt { get; init; }
|
||||
|
||||
public DateTimeOffset? AnsweredAt { get; init; }
|
||||
|
||||
/// <summary>The server confirmed the deletion twice (design §6.3): the pair reads "deleted on server".</summary>
|
||||
public bool RemoteGone => RemoteGoneHits >= 2;
|
||||
|
||||
/// <summary>Shown in Server › Matches: everything but the plain links every upload or download makes.</summary>
|
||||
public bool IsListed => Evidence != CopyEvidence.Link || State is not CopyState.Linked || RemoteGone || Score.DeletedThere > 0;
|
||||
|
||||
/// <summary>Draws the chip in warning colours, counts in the Server rail badge and gives the Library card its status.</summary>
|
||||
public bool NeedsAttention => State == CopyState.Candidate || (RemoteGone && State != CopyState.KeptApart)
|
||||
|| (State is CopyState.Integrated or CopyState.Linked && (Score.DeletedThere > 0 || Score.DeletedHere > 0));
|
||||
|
||||
/// <summary>Whether <paramref name="sequenceId"/> is one of the pair's local sequences.</summary>
|
||||
public bool Names(Guid sequenceId) => LocalId == sequenceId || OtherId == sequenceId;
|
||||
}
|
||||
|
||||
/// <summary>What detection last sent or compared of a local sequence, per scope (a server key, or "" for this PC's archives).</summary>
|
||||
public sealed record CopyProbe(Guid SequenceId, string Scope, int FramesVersion, int Hashed, DateTimeOffset ProbedAt);
|
||||
|
||||
/// <summary>What one detection run found: new pairs, pairs it linked by itself, and kept-apart pairs that ask again.</summary>
|
||||
public sealed record CopyFindResult(IReadOnlyList<FoundCopy> New, IReadOnlyList<FoundCopy> AutoLinked, IReadOnlyList<FoundCopy> AskedAgain)
|
||||
{
|
||||
public static CopyFindResult Empty { get; } = new([], [], []);
|
||||
|
||||
public bool IsEmpty => New.Count == 0 && AutoLinked.Count == 0 && AskedAgain.Count == 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// What a state change records (<see cref="FoundCopyStore.SetStateAsync"/>): the fingerprint and shared count a Keep apart
|
||||
/// was given, the job of an Integrating pair, the pair's auto-photos policy; null members leave the stored value.
|
||||
/// </summary>
|
||||
public sealed record CopyAnswer(string? Fingerprint, int? Shared, Guid? JobId, bool? AutoPhotos, DateTimeOffset At);
|
||||
|
||||
/// <summary>Two local sequences sharing content: SHA-256 counts, tombstoned content, size and capture time (design §2.4).</summary>
|
||||
public sealed record LocalOverlap(Guid Low, Guid High, int SharedHashes, int SharedRemoved, int SharedUnhashed);
|
||||
|
||||
/// <summary>What the links stage of a merge moved (<see cref="FoundCopyStore.MoveToKeptAsync"/>).</summary>
|
||||
public sealed record MoveResult(int SessionKeys, IReadOnlyList<string> SkippedKeys, int Links, int Pairs);
|
||||
|
||||
/// <summary>One side's hints (design §3.1): capture range, camera, median interval and title.</summary>
|
||||
public sealed record CopyHintsInput(DateTime? First, DateTime? Last, string? Camera, double? MedianInterval, string? Title);
|
||||
|
||||
/// <summary>
|
||||
/// The inputs of 1.1's gate: both unlinked, first captures (to the second), camera models, local hashed count, the server's
|
||||
/// frame count, and the shared canonical hash count.
|
||||
/// </summary>
|
||||
public sealed record SameOriginalsInput(bool BothUnlinked, DateTime? LocalFirst, DateTime? RemoteFirst, string? LocalCamera,
|
||||
string? RemoteCamera, int LocalHashed, int RemoteFrames, int SharedCanonical);
|
||||
@@ -0,0 +1,173 @@
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Data.Archiving;
|
||||
using Chronos.Data.Projects;
|
||||
using Chronos.Data.Sync;
|
||||
|
||||
namespace Chronos.Data.Copies;
|
||||
|
||||
/// <summary>The user's choice for one photo under Choose each (nothing preselected: <see cref="Leave"/>).</summary>
|
||||
public enum PhotoChoice
|
||||
{
|
||||
Leave = 0,
|
||||
Bring = 1,
|
||||
KeepBoth = 2,
|
||||
TakeHere = 3,
|
||||
TakeThere = 4,
|
||||
}
|
||||
|
||||
/// <summary>What a plan does with one photo.</summary>
|
||||
public enum PhotoAction
|
||||
{
|
||||
Send = 0,
|
||||
Fetch = 1,
|
||||
SendVersion = 2,
|
||||
FetchVersion = 3,
|
||||
TrashHere = 4,
|
||||
TrashThere = 5,
|
||||
}
|
||||
|
||||
/// <summary>Why a plan cannot be applied (each maps to one <c>Errors.Copies.*</c> key).</summary>
|
||||
public enum CopyBlock
|
||||
{
|
||||
NeedsNewerServer,
|
||||
NoUploadRight,
|
||||
NoFetchRight,
|
||||
NoEditRight,
|
||||
NoDeleteRight,
|
||||
LinkTaken,
|
||||
NoSpace,
|
||||
Busy,
|
||||
ArchiveOffline,
|
||||
DetailsUnchosen,
|
||||
FolderMoved,
|
||||
UnsentWorkspace,
|
||||
BothLinked,
|
||||
TrashBlocked,
|
||||
KeptUnchosen,
|
||||
ChangedFile,
|
||||
}
|
||||
|
||||
/// <summary>The choices of an Integrate: photo policy, per-photo choices (by photo key), per-detail sides (by path), projects.</summary>
|
||||
public sealed record IntegrateChoices(CopyPhotoPolicy Photos, IReadOnlyDictionary<string, PhotoChoice> PerPhoto,
|
||||
IReadOnlyDictionary<string, CopySide> Details, CopyProjects Projects);
|
||||
|
||||
/// <summary>One photo step of a plan: the photo's key, what is done, the frame it starts from, its name, size and SHA-256.</summary>
|
||||
public sealed record PhotoStep(string Key, PhotoAction Action, Guid? FrameId, string FileName, long Bytes, string? Sha256);
|
||||
|
||||
/// <summary>A photo a trash step takes whose raw SHA-256 nothing else holds (no other frame of this index, nor the other side).</summary>
|
||||
public sealed record LastCopy(string Key, CopySide Side, string FileName, long Bytes);
|
||||
|
||||
/// <summary>A project copied across: from which side, the source, the name it gets at the other home, its versions and head.</summary>
|
||||
public sealed record ProjectStep(CopySide From, Guid SourceProjectId, string SourceName, string TargetName, int Versions, Guid SourceHeadId);
|
||||
|
||||
/// <summary>
|
||||
/// The dry run of an Integrate of a local sequence with a server sequence (design §5c). Payload is the one portable payload
|
||||
/// both sides get; LocalPayload and RemotePayload are each side's as planned (the apply-time content check).
|
||||
/// </summary>
|
||||
public sealed record IntegratePlan(Guid CopyId, string Server, Guid LocalId, Guid RemoteId, IntegrateChoices Choices,
|
||||
IReadOnlyList<PhotoStep> Photos, IReadOnlyList<LastCopy> LastCopies, int LeftOut, SyncPayload? Payload,
|
||||
SyncPayload? LocalPayload, SyncPayload? RemotePayload, int DetailChanges, IReadOnlyList<ProjectStep> Projects,
|
||||
long FetchBytes, long SendBytes, long FreeBytes, long? QuotaLeftBytes, IReadOnlyList<CopyBlock> Blocks,
|
||||
int LocalFramesVersion, int LocalSettingsVersion, int RemoteFramesVersion, int RemoteSettingsVersion, string Fingerprint)
|
||||
{
|
||||
public bool CanApply => Blocks.Count == 0;
|
||||
|
||||
public bool Destructive => Photos.Any(p => p.Action is PhotoAction.TrashHere or PhotoAction.TrashThere);
|
||||
|
||||
/// <summary>New photos move by themselves afterwards only when the plan leaves nothing on one side only (design §6.1).</summary>
|
||||
public bool AutoPhotos => LeftOut == 0;
|
||||
}
|
||||
|
||||
/// <summary>The choices of a merge of two local copies (projects are always copied across: the other's home goes to the trash).</summary>
|
||||
public sealed record MergeChoices(CopyPhotoPolicy Photos, IReadOnlyDictionary<string, PhotoChoice> PerPhoto,
|
||||
IReadOnlyDictionary<string, CopySide> Details);
|
||||
|
||||
/// <summary>A render of the dropped sequence that moves to the kept one (its row keeps its id).</summary>
|
||||
public sealed record RenderStep(Guid RenderId, string FileName, long Bytes, string? Sha256);
|
||||
|
||||
/// <summary>The dry run of a merge of two local sequences into the kept one (design §5d).</summary>
|
||||
public sealed record MergePlan(Guid CopyId, Guid KeepId, Guid DropId, MergeChoices Choices, IReadOnlyList<PhotoStep> Photos,
|
||||
IReadOnlyList<LastCopy> LastCopies, IReadOnlyList<RenderStep> Renders, SyncPayload? Payload, int DetailChanges,
|
||||
IReadOnlyList<ProjectStep> Projects, IReadOnlyList<string> SessionKeys, IReadOnlyList<string> SkippedSessionKeys,
|
||||
IReadOnlyList<string> Links, DeletePlan Trash, long CopyBytes, long FreeBytes, IReadOnlyList<CopyBlock> Blocks,
|
||||
int KeepFramesVersion, int KeepSettingsVersion, int DropFramesVersion, int DropSettingsVersion, string Fingerprint)
|
||||
{
|
||||
public bool CanApply => Blocks.Count == 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// What the planners need to know of this PC and the signed-in account: names, rights (OwnsOrAdmin: of the server sequence),
|
||||
/// whether the server keeps projects, the quota left, sequences with unsent workspace work, and every server's originals archive.
|
||||
/// </summary>
|
||||
public sealed record CopyPlanContext(string PcName, string? ServerName, bool CanUpload, bool CanFetch, bool CanEdit, bool CanDelete,
|
||||
bool OwnsOrAdmin, bool KeepsProjects, long? QuotaLeft, IReadOnlySet<Guid> UnsentWorkspaceSequences,
|
||||
IReadOnlySet<Guid> ServerOriginalsArchives);
|
||||
|
||||
/// <summary>The server-side dry run of moving photos of a pair's server sequence to the server's trash (design §6.2).</summary>
|
||||
public sealed record TrashTherePlan(Guid CopyId, string Server, Guid RemoteId, IReadOnlyList<Guid> FrameIds, IReadOnlyList<string> Keys, int Photos,
|
||||
long Bytes, int FramesVersion, IReadOnlyList<LastCopy> LastCopies);
|
||||
|
||||
/// <summary>
|
||||
/// The journal of one project copied to another home: the intended name, when it was asked, the copy once made, the version
|
||||
/// the copy was made from, and the versions pushed so far (source version id to the copy's).
|
||||
/// </summary>
|
||||
public sealed record TransplantStep(string Intent, DateTimeOffset Asked, Guid? TargetId, Guid? BaseId, int BaseNumber,
|
||||
IReadOnlyList<TransplantMove> Moves);
|
||||
|
||||
/// <summary>A version of the source project and its copy at the other home.</summary>
|
||||
public sealed record TransplantMove(Guid Source, Guid Copy);
|
||||
|
||||
/// <summary>Copies a project with its whole history from one home to another (ProjectTransplant).</summary>
|
||||
public interface IProjectCopier
|
||||
{
|
||||
Task<SequenceProject> CopyAsync(IProjectHome from, SequenceProject source, IProjectHome to, string name,
|
||||
TransplantStep? journal, Func<TransplantStep, ValueTask> save, CancellationToken ct);
|
||||
}
|
||||
|
||||
/// <summary>Whether a sequence has workspace projects with unsent versions or unsaved work (a merge waits for them).</summary>
|
||||
public interface IWorkspaceGuard
|
||||
{
|
||||
Task<bool> HasUnsentAsync(Guid sequenceId, CancellationToken ct);
|
||||
}
|
||||
|
||||
/// <summary>The sequences changed since the plan was made: nothing was applied; the pair goes back to its previous state.</summary>
|
||||
public sealed class StaleCopyPlanException : InvalidOperationException
|
||||
{
|
||||
public StaleCopyPlanException()
|
||||
: base(Loc.L("Errors.Copies.StalePlan"))
|
||||
{
|
||||
}
|
||||
|
||||
public StaleCopyPlanException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public StaleCopyPlanException(string message, Exception inner)
|
||||
: base(message, inner)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A sequence of the pair is already linked to another sequence of that server: nothing was changed.</summary>
|
||||
public sealed class CopyLinkTakenException : InvalidOperationException
|
||||
{
|
||||
public CopyLinkTakenException()
|
||||
: base(Loc.L("Errors.Copies.LinkTaken", string.Empty, string.Empty))
|
||||
{
|
||||
}
|
||||
|
||||
public CopyLinkTakenException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public CopyLinkTakenException(string message, Exception inner)
|
||||
: base(message, inner)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>The refusal for <paramref name="title"/> already linked to another sequence of <paramref name="server"/>.</summary>
|
||||
public static CopyLinkTakenException For(string title, string server) => new(Loc.L("Errors.Copies.LinkTaken", title, server));
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Data.Sync;
|
||||
|
||||
namespace Chronos.Data.Copies;
|
||||
|
||||
/// <summary>One difference of title, tags, rating, notes or settings between two copies (a JSON path, both values as shown).</summary>
|
||||
public sealed record DetailLine(string Path, string? Here, string? There);
|
||||
|
||||
/// <summary>A project of one home, as the Projects part lists it.</summary>
|
||||
public sealed record ProjectLine(Guid Id, string Name, bool IsMain, int Versions, Guid HeadId, string HeadHash, DateTimeOffset UpdatedAt);
|
||||
|
||||
/// <summary>
|
||||
/// Both homes' projects. MainSame: the two Main heads make the same choices; ThereKeepsProjects: the other home keeps
|
||||
/// projects (a server without the <c>projects</c> capability keeps none).
|
||||
/// </summary>
|
||||
public sealed record CopyProjectsView(IReadOnlyList<ProjectLine> Here, IReadOnlyList<ProjectLine> There, bool MainSame, bool ThereKeepsProjects);
|
||||
|
||||
/// <summary>Renders of each side, and those both hold (by render id, or by SHA-256 where both record one).</summary>
|
||||
public sealed record CopyRendersView(int Here, int There, int Shared, long HereBytes, long ThereBytes);
|
||||
|
||||
/// <summary>
|
||||
/// The facts of one side: title, where it lies (archive or server name), photos, bytes, capture range, camera, hashed count,
|
||||
/// origin, the servers the local copy is linked to, and whether it lies in a server's originals archive.
|
||||
/// </summary>
|
||||
public sealed record CopyFacts(string Title, string Where, Guid? ArchiveId, int Photos, long Bytes, DateTime? First, DateTime? Last,
|
||||
string? Camera, int Hashed, SequenceOrigin? Origin, IReadOnlyList<string> Servers, bool InOriginalsArchive);
|
||||
|
||||
/// <summary>What the Compare dialog shows of a pair: both sides, the photos, the details line by line, projects, renders, and what can be done.</summary>
|
||||
public sealed record CopyReview(FoundCopy Copy, CopyFacts Here, CopyFacts There, CopyComparisonResult Photos,
|
||||
IReadOnlyList<DetailLine> Details, CopyProjectsView Projects, CopyRendersView Renders, CopyCapabilities Can);
|
||||
|
||||
/// <summary>Whether Integrate (or Merge), Link only and Delete on server are possible, and why not (<see cref="CopyBlock"/>s).</summary>
|
||||
public sealed record CopyCapabilities(bool Integrate, bool LinkOnly, bool DeleteThere, IReadOnlyList<CopyBlock> Blocks);
|
||||
|
||||
/// <summary>A row of Server › Matches: the pair with the facts of both sides (the other side's from the server listing or the other archive).</summary>
|
||||
public sealed record FoundCopyView(FoundCopy Copy, CopyFacts Here, CopyFacts There);
|
||||
|
||||
/// <summary>
|
||||
/// The same time-lapse with workspace projects at two homes (a linked or integrated pair): the Edit picker marks each as the
|
||||
/// other's twin. LocalHome names the local copy's archive; a project name is null when that home has no workspace project.
|
||||
/// </summary>
|
||||
public sealed record CopyTwin(Guid CopyId, Guid LocalId, string LocalHome, string? LocalProject, string Server, Guid RemoteId, string? ServerProject);
|
||||
@@ -0,0 +1,565 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Data.Repositories;
|
||||
using Chronos.Data.Sync;
|
||||
|
||||
namespace Chronos.Data.Copies;
|
||||
|
||||
/// <summary>
|
||||
/// The <c>found_copies</c> and <c>copy_probes</c> tables (owner review 6, #73; migration 0012): pairs of copies of one
|
||||
/// time-lapse, their scores, answers and policies, and what detection last probed. <c>sync_links</c> stays the 1:1 record a
|
||||
/// sync compares; every link has a row here too (evidence <see cref="CopyEvidence.Link"/>). A local pair is stored once,
|
||||
/// ordered (<see cref="Order"/>).
|
||||
/// </summary>
|
||||
public sealed class FoundCopyStore(ChronosDatabase db, TimeProvider? time = null)
|
||||
{
|
||||
private const string Columns =
|
||||
"id, kind, local_id, server, remote_id, other_id, evidence, state, shared, shared_unhashed, shared_removed, only_here, only_there, " +
|
||||
"differs, deleted_here, deleted_there, versions, local_photos, other_photos, containment, overlap, hints, local_frames_version, " +
|
||||
"other_frames_version, fingerprint, answered_fingerprint, answered_shared, auto_photos, job_id, previous_state, remote_gone_at, " +
|
||||
"remote_gone_hits, found_at, updated_at, answered_at";
|
||||
|
||||
/// <summary>
|
||||
/// The state a row reads as: an Integrating row whose job is Failed, Cancelled or missing reads as its previous state
|
||||
/// (the backstop for a crash before the job could set it back; a Done job's handler sets the end state itself).
|
||||
/// </summary>
|
||||
private const string Effective =
|
||||
"(CASE WHEN found_copies.state = 3 AND (found_copies.job_id IS NULL OR NOT EXISTS (SELECT 1 FROM jobs j " +
|
||||
"WHERE j.id = found_copies.job_id AND j.state NOT IN (4, 5))) THEN COALESCE(found_copies.previous_state, 0) " +
|
||||
"ELSE found_copies.state END)";
|
||||
|
||||
private static readonly string Select = $"SELECT {Columns}, {Effective} AS effective_state FROM found_copies";
|
||||
|
||||
private static readonly string ProbeUpsert = SqlDialect.Upsert("copy_probes", ["sequence_id", "scope", "frames_version", "hashed", "probed_at"], 2);
|
||||
|
||||
/// <summary>The refresh that last counted a 404 for each remote, per database (a refresh id is new after every start).</summary>
|
||||
private static readonly ConditionalWeakTable<IDatabase, ConcurrentDictionary<(string Server, Guid RemoteId), Guid>> GoneRefreshes = new();
|
||||
|
||||
private static readonly CopyState[] Ranks = [CopyState.Candidate, CopyState.Linked, CopyState.KeptApart, CopyState.Integrated, CopyState.Integrating];
|
||||
|
||||
private readonly DbAccess _db = new(db.Database);
|
||||
private readonly TimeProvider _time = time ?? TimeProvider.System;
|
||||
|
||||
/// <summary>The order a local pair is stored in: the smaller id by ordinal comparison of the "D" strings (PostgreSQL's uuid order).</summary>
|
||||
public static (Guid Low, Guid High) Order(Guid a, Guid b) =>
|
||||
string.CompareOrdinal(a.ToString("D"), b.ToString("D")) <= 0 ? (a, b) : (b, a);
|
||||
|
||||
/// <summary>Every row, oldest first.</summary>
|
||||
public Task<IReadOnlyList<FoundCopy>> ListAsync(CancellationToken ct) =>
|
||||
_db.ListAsync($"{Select} ORDER BY found_at, id", [], Map, ct);
|
||||
|
||||
/// <summary>The local↔server rows of <paramref name="server"/>.</summary>
|
||||
public Task<IReadOnlyList<FoundCopy>> ListByServerAsync(string server, CancellationToken ct) =>
|
||||
_db.ListAsync($"{Select} WHERE kind = 0 AND server = $1 ORDER BY found_at, id", [server], Map, ct);
|
||||
|
||||
/// <summary>The rows naming <paramref name="sequenceId"/> on either local side.</summary>
|
||||
public Task<IReadOnlyList<FoundCopy>> ListByLocalAsync(Guid sequenceId, CancellationToken ct) =>
|
||||
_db.ListAsync($"{Select} WHERE local_id = $1 OR other_id = $1 ORDER BY found_at, id", [sequenceId], Map, ct);
|
||||
|
||||
public Task<FoundCopy?> GetAsync(Guid id, CancellationToken ct) =>
|
||||
_db.SingleAsync($"{Select} WHERE id = $1", [id], Map, ct);
|
||||
|
||||
public Task<FoundCopy?> FindRemoteAsync(Guid localId, string server, Guid remoteId, CancellationToken ct) =>
|
||||
FindRemoteAsync(_db, localId, server, remoteId, ct);
|
||||
|
||||
public Task<FoundCopy?> FindLocalAsync(Guid a, Guid b, CancellationToken ct)
|
||||
{
|
||||
var (low, high) = Order(a, b);
|
||||
return _db.SingleAsync($"{Select} WHERE kind = 1 AND local_id = $1 AND other_id = $2", [low, high], Map, ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts a new row, or updates evidence (the stronger is kept), scores, versions and fingerprint of the row of the same
|
||||
/// pair; never its state, answer, policy or job (those change only through <see cref="SetStateAsync"/>). A local pair
|
||||
/// given in the other order is stored ordered, its sides swapped. Returns the stored row.
|
||||
/// </summary>
|
||||
public async Task<FoundCopy> UpsertFoundAsync(FoundCopy copy, CancellationToken ct)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(copy);
|
||||
copy = Normalised(copy);
|
||||
var now = _time.GetUtcNow();
|
||||
return await _db.InTransactionAsync(async session =>
|
||||
{
|
||||
var inner = new DbAccess(session);
|
||||
var existing = copy.Kind == CopyKind.LocalServer
|
||||
? await FindRemoteAsync(inner, copy.LocalId, copy.Server!, copy.RemoteId!.Value, ct).ConfigureAwait(false)
|
||||
: await inner.SingleAsync($"{Select} WHERE kind = 1 AND local_id = $1 AND other_id = $2", [copy.LocalId, copy.OtherId!.Value], Map, ct)
|
||||
.ConfigureAwait(false);
|
||||
var s = copy.Score;
|
||||
if (existing is null)
|
||||
{
|
||||
var id = copy.Id == Guid.Empty ? Guid.NewGuid() : copy.Id;
|
||||
await InsertAsync(inner, copy with { Id = id, FoundAt = copy.FoundAt == default ? now : copy.FoundAt }, now, ct).ConfigureAwait(false);
|
||||
return (await inner.SingleAsync($"{Select} WHERE id = $1", [id], Map, ct).ConfigureAwait(false))!;
|
||||
}
|
||||
await inner.ExecuteAsync(
|
||||
"UPDATE found_copies SET evidence = $2, shared = $3, shared_unhashed = $4, shared_removed = $5, only_here = $6, only_there = $7, " +
|
||||
"differs = $8, deleted_here = $9, deleted_there = $10, versions = $11, local_photos = $12, other_photos = $13, containment = $14, " +
|
||||
"overlap = $15, hints = $16, local_frames_version = $17, other_frames_version = $18, fingerprint = $19, updated_at = $20 WHERE id = $1",
|
||||
[
|
||||
existing.Id, Math.Min((int)existing.Evidence, (int)copy.Evidence), s.Shared, s.SharedUnhashed, s.SharedRemoved, s.OnlyHere,
|
||||
s.OnlyThere, s.Differs, s.DeletedHere, s.DeletedThere, s.Versions, s.LocalPhotos, s.OtherPhotos, s.Containment, s.Overlap,
|
||||
s.Hints, copy.LocalFramesVersion, copy.OtherFramesVersion, copy.Fingerprint, now,
|
||||
], ct).ConfigureAwait(false);
|
||||
return (await inner.SingleAsync($"{Select} WHERE id = $1", [existing.Id], Map, ct).ConfigureAwait(false))!;
|
||||
}, ct).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compare-and-set of the state (<paramref name="expected"/> null: any), against the state the row reads as. False when
|
||||
/// the row moved on meanwhile or is gone. Entering <see cref="CopyState.Integrating"/> needs the job
|
||||
/// (<see cref="CopyAnswer.JobId"/>) and stores the state it leaves as <see cref="FoundCopy.PreviousState"/>; leaving it
|
||||
/// clears both. The answer's fingerprint and shared count (a Keep apart) and its time are recorded when given; auto
|
||||
/// photos hold only for <see cref="CopyState.Integrated"/> (any other state clears them).
|
||||
/// </summary>
|
||||
public async Task<bool> SetStateAsync(Guid id, CopyState? expected, CopyState state, CopyAnswer? answer, CancellationToken ct)
|
||||
{
|
||||
if (state == CopyState.Integrating && answer?.JobId is null)
|
||||
throw new ArgumentException("A pair enters Integrating with the job that integrates it.", nameof(answer));
|
||||
var now = _time.GetUtcNow();
|
||||
var integrating = state == CopyState.Integrating;
|
||||
var changed = await _db.ExecuteAsync(
|
||||
"UPDATE found_copies SET " +
|
||||
$"previous_state = {(integrating ? $"CASE WHEN {Effective} = 3 THEN previous_state ELSE {Effective} END" : "NULL")}, " +
|
||||
$"job_id = {(integrating ? "$3" : "NULL")}, " +
|
||||
"state = $2, " +
|
||||
"answered_fingerprint = COALESCE($4, answered_fingerprint), " +
|
||||
"answered_shared = COALESCE($5, answered_shared), " +
|
||||
"answered_at = COALESCE($6, answered_at), " +
|
||||
"auto_photos = CASE WHEN $2 = 4 THEN COALESCE($7, auto_photos) ELSE $8 END, " +
|
||||
"updated_at = $9 " +
|
||||
$"WHERE id = $1{(expected is { } e ? $" AND {Effective} = {(int)e}" : string.Empty)}",
|
||||
[
|
||||
id, (int)state, answer?.JobId, DbParam.Text(answer?.Fingerprint), answer?.Shared,
|
||||
(DateTimeOffset?)answer?.At, answer?.AutoPhotos, false, now,
|
||||
], ct).ConfigureAwait(false);
|
||||
return changed == 1;
|
||||
}
|
||||
|
||||
/// <summary>The counts of a new exact comparison, at the frames versions it read.</summary>
|
||||
public Task UpdateScoreAsync(Guid id, CopyScore score, int localFramesVersion, int otherFramesVersion, string fingerprint, CancellationToken ct)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(score);
|
||||
ArgumentNullException.ThrowIfNull(fingerprint);
|
||||
var s = score;
|
||||
return _db.ExecuteAsync(
|
||||
"UPDATE found_copies SET shared = $2, shared_unhashed = $3, shared_removed = $4, only_here = $5, only_there = $6, differs = $7, " +
|
||||
"deleted_here = $8, deleted_there = $9, versions = $10, local_photos = $11, other_photos = $12, containment = $13, overlap = $14, " +
|
||||
"hints = $15, local_frames_version = $16, other_frames_version = $17, fingerprint = $18, updated_at = $19 WHERE id = $1",
|
||||
[
|
||||
id, s.Shared, s.SharedUnhashed, s.SharedRemoved, s.OnlyHere, s.OnlyThere, s.Differs, s.DeletedHere, s.DeletedThere, s.Versions,
|
||||
s.LocalPhotos, s.OtherPhotos, s.Containment, s.Overlap, s.Hints, localFramesVersion, otherFramesVersion, fingerprint, _time.GetUtcNow(),
|
||||
], ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The row of a link (evidence Link, state Linked) when it has none; the link's row otherwise kept (moved to Linked when it
|
||||
/// was a Candidate). Any other Linked or Integrated row of the same server sequence, or of the same local sequence and
|
||||
/// server, is demoted to Candidate (a link re-pointed to another copy: sync_links holds one link per side and server).
|
||||
/// </summary>
|
||||
public Task<FoundCopy> EnsureLinkedAsync(string server, Guid remoteId, Guid localId, CancellationToken ct)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(server);
|
||||
return _db.InTransactionAsync(session => EnsureLinkedAsync(new DbAccess(session), server, remoteId, localId, ct), ct);
|
||||
}
|
||||
|
||||
private async Task<FoundCopy> EnsureLinkedAsync(DbAccess inner, string server, Guid remoteId, Guid localId, CancellationToken ct)
|
||||
{
|
||||
var now = _time.GetUtcNow();
|
||||
var row = await FindRemoteAsync(inner, localId, server, remoteId, ct).ConfigureAwait(false);
|
||||
if (row is null)
|
||||
{
|
||||
row = LinkRow(server, remoteId, localId, now);
|
||||
await InsertAsync(inner, row, now, ct).ConfigureAwait(false);
|
||||
}
|
||||
else if (row.State == CopyState.Candidate)
|
||||
{
|
||||
await inner.ExecuteAsync("UPDATE found_copies SET state = 2, previous_state = NULL, job_id = NULL, auto_photos = $2, updated_at = $3 WHERE id = $1",
|
||||
[row.Id, false, now], ct).ConfigureAwait(false);
|
||||
}
|
||||
await DemoteAsync(inner, server, remoteId, localId, now, ct).ConfigureAwait(false);
|
||||
return (await inner.SingleAsync($"{Select} WHERE id = $1", [row.Id], Map, ct).ConfigureAwait(false))!;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A 404 for the remote side (design §6.3): nothing when <paramref name="localId"/> is null (an observation-only link);
|
||||
/// else the pair's row (made when the link had none) counts one hit per <paramref name="refreshId"/> and every Candidate
|
||||
/// row naming that remote is deleted.
|
||||
/// </summary>
|
||||
public async Task MarkRemoteGoneAsync(string server, Guid remoteId, Guid? localId, Guid refreshId, DateTimeOffset at, CancellationToken ct)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(server);
|
||||
if (localId is not { } local) return;
|
||||
var refreshes = GoneRefreshes.GetOrCreateValue(db.Database);
|
||||
var counted = refreshes.TryGetValue((server, remoteId), out var last) && last == refreshId;
|
||||
await _db.InTransactionAsync(async session =>
|
||||
{
|
||||
var inner = new DbAccess(session);
|
||||
var row = await FindRemoteAsync(inner, local, server, remoteId, ct).ConfigureAwait(false);
|
||||
if (row is null)
|
||||
{
|
||||
row = LinkRow(server, remoteId, local, _time.GetUtcNow());
|
||||
await InsertAsync(inner, row, _time.GetUtcNow(), ct).ConfigureAwait(false);
|
||||
}
|
||||
if (!counted)
|
||||
{
|
||||
await inner.ExecuteAsync(
|
||||
"UPDATE found_copies SET remote_gone_hits = remote_gone_hits + 1, remote_gone_at = COALESCE(remote_gone_at, $2), updated_at = $3 WHERE id = $1",
|
||||
[row.Id, at, _time.GetUtcNow()], ct).ConfigureAwait(false);
|
||||
}
|
||||
await inner.ExecuteAsync($"DELETE FROM found_copies WHERE kind = 0 AND server = $1 AND remote_id = $2 AND id <> $3 AND {Effective} = 0",
|
||||
[server, remoteId, row.Id], ct).ConfigureAwait(false);
|
||||
return 0;
|
||||
}, ct).ConfigureAwait(false);
|
||||
refreshes[(server, remoteId)] = refreshId;
|
||||
}
|
||||
|
||||
/// <summary>The server answered for the remote again: hits back to 0, no gone time.</summary>
|
||||
public Task ClearRemoteGoneAsync(string server, Guid remoteId, CancellationToken ct)
|
||||
{
|
||||
if (GoneRefreshes.TryGetValue(db.Database, out var refreshes)) refreshes.TryRemove((server, remoteId), out _);
|
||||
return _db.ExecuteAsync(
|
||||
"UPDATE found_copies SET remote_gone_hits = 0, remote_gone_at = NULL, updated_at = $3 " +
|
||||
"WHERE kind = 0 AND server = $1 AND remote_id = $2 AND (remote_gone_hits <> 0 OR remote_gone_at IS NOT NULL)",
|
||||
[server, remoteId, _time.GetUtcNow()], ct);
|
||||
}
|
||||
|
||||
public Task DeleteAsync(Guid id, CancellationToken ct) =>
|
||||
_db.ExecuteAsync("DELETE FROM found_copies WHERE id = $1", [id], ct);
|
||||
|
||||
/// <summary>
|
||||
/// Moves the pairs and probes of <paramref name="from"/> to <paramref name="to"/> inside the caller's transaction (the one
|
||||
/// <see cref="SyncLinkStore.RekeyAsync"/> moves the links in; design §2.5), after the links moved. On a clash the row
|
||||
/// matching the link that survived wins (the moved one when its remote is in <paramref name="survivingLinkRemotes"/>, the
|
||||
/// one already under the new key otherwise); else the higher state (Integrating, Integrated, Kept apart, Linked,
|
||||
/// Candidate), then the newer update. Linked and Integrated rows no surviving link backs become Candidates.
|
||||
/// </summary>
|
||||
internal async Task<(int Moved, int Dropped)> RekeyAsync(IDbSession session, string from, string to, IReadOnlySet<Guid> survivingLinkRemotes,
|
||||
CancellationToken ct)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(session);
|
||||
ArgumentNullException.ThrowIfNull(survivingLinkRemotes);
|
||||
if (string.Equals(from, to, StringComparison.Ordinal)) return (0, 0);
|
||||
var inner = new DbAccess(session);
|
||||
var now = _time.GetUtcNow();
|
||||
var old = await inner.ListAsync($"{Select} WHERE kind = 0 AND server = $1 ORDER BY found_at, id", [from], Map, ct).ConfigureAwait(false);
|
||||
var current = (await inner.ListAsync($"{Select} WHERE kind = 0 AND server = $1 ORDER BY found_at, id", [to], Map, ct).ConfigureAwait(false)).ToList();
|
||||
var links = (await inner.ListAsync("SELECT remote_id, local_id FROM sync_links WHERE server = $1 AND local_id IS NOT NULL", [to],
|
||||
r => (Remote: r.GetGuid(0), Local: r.GetGuid(1)), ct).ConfigureAwait(false)).ToDictionary(l => l.Remote, l => l.Local);
|
||||
var (moved, dropped) = (0, 0);
|
||||
foreach (var row in old)
|
||||
{
|
||||
var clash = current.FirstOrDefault(c => c.LocalId == row.LocalId && c.RemoteId == row.RemoteId);
|
||||
if (clash is not null)
|
||||
{
|
||||
var backed = links.TryGetValue(row.RemoteId!.Value, out var linked) && linked == row.LocalId;
|
||||
var keepMoved = backed ? survivingLinkRemotes.Contains(row.RemoteId.Value) : Wins(row, clash);
|
||||
var loser = keepMoved ? clash : row;
|
||||
await inner.ExecuteAsync("DELETE FROM found_copies WHERE id = $1", [loser.Id], ct).ConfigureAwait(false);
|
||||
dropped++;
|
||||
if (!keepMoved) continue;
|
||||
current.Remove(clash);
|
||||
}
|
||||
await inner.ExecuteAsync("UPDATE found_copies SET server = $2 WHERE id = $1", [row.Id, to], ct).ConfigureAwait(false);
|
||||
current.Add(row with { Server = to });
|
||||
moved++;
|
||||
}
|
||||
// Rows no link backs any more (a link of the old key lost to the new key's, or the other way round).
|
||||
foreach (var row in current.Where(c => c.State is CopyState.Linked or CopyState.Integrated))
|
||||
{
|
||||
if (links.TryGetValue(row.RemoteId!.Value, out var local) && local == row.LocalId) continue;
|
||||
if (!links.ContainsKey(row.RemoteId.Value) && !links.ContainsValue(row.LocalId)) continue;
|
||||
await inner.ExecuteAsync("UPDATE found_copies SET state = 0, auto_photos = $2, updated_at = $3 WHERE id = $1 AND state IN (2, 4)",
|
||||
[row.Id, false, now], ct).ConfigureAwait(false);
|
||||
}
|
||||
await inner.ExecuteAsync(
|
||||
"DELETE FROM copy_probes WHERE scope = $1 AND sequence_id IN (SELECT sequence_id FROM copy_probes WHERE scope = $2)", [from, to], ct)
|
||||
.ConfigureAwait(false);
|
||||
await inner.ExecuteAsync("UPDATE copy_probes SET scope = $2 WHERE scope = $1", [from, to], ct).ConfigureAwait(false);
|
||||
return (moved, dropped);
|
||||
|
||||
static bool Wins(FoundCopy moving, FoundCopy staying)
|
||||
{
|
||||
var (a, b) = (Array.IndexOf(Ranks, moving.State), Array.IndexOf(Ranks, staying.State));
|
||||
return a != b ? a > b : moving.UpdatedAt > staying.UpdatedAt;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The links stage of a merge (design §5d), one transaction: session keys, links and pairs of <paramref name="drop"/>
|
||||
/// move to <paramref name="keep"/>. A key <paramref name="keepArchiveId"/> already maps to a third sequence is skipped
|
||||
/// (returned in <see cref="MoveResult.SkippedKeys"/>). Links take keep with their agreement reset (the next comparison
|
||||
/// agrees equal payloads and makes a Conflict of different ones, never a push). Pairs naming drop name keep; a pair of
|
||||
/// keep with itself is deleted; on a clash keep's row stays; moved Integrated pairs become Linked without auto photos.
|
||||
/// The pair <paramref name="exceptCopyId"/> (the merge's own) is left untouched. Refused before any change
|
||||
/// (<see cref="CopyLinkTakenException"/>) when keep and drop are linked to sequences of one server. Idempotent.
|
||||
/// </summary>
|
||||
public Task<MoveResult> MoveToKeptAsync(Guid drop, Guid keep, Guid keepArchiveId, IReadOnlyCollection<string> sessionKeys, Guid? exceptCopyId,
|
||||
CancellationToken ct)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(sessionKeys);
|
||||
if (drop == keep) throw new ArgumentException("A sequence is never merged into itself.", nameof(keep));
|
||||
var now = _time.GetUtcNow();
|
||||
return _db.InTransactionAsync(async session =>
|
||||
{
|
||||
var inner = new DbAccess(session);
|
||||
var linked = await inner.ListAsync("SELECT server, local_id FROM sync_links WHERE local_id = $1 OR local_id = $2", [drop, keep],
|
||||
r => (Server: r.GetString(0), Local: r.GetGuid(1)), ct).ConfigureAwait(false);
|
||||
var both = linked.GroupBy(l => l.Server, StringComparer.Ordinal).FirstOrDefault(g => g.Select(l => l.Local).Distinct().Count() > 1);
|
||||
if (both is not null) throw new CopyLinkTakenException(Loc.L("Errors.Copies.BothLinked", both.Key));
|
||||
|
||||
// (1) Session keys.
|
||||
var (keys, skipped) = (0, new List<string>());
|
||||
foreach (var key in sessionKeys.Distinct(StringComparer.Ordinal))
|
||||
{
|
||||
var holder = await inner.ScalarAsync<Guid?>("SELECT sequence_id FROM sequence_sessions WHERE archive_id = $1 AND session_key = $2",
|
||||
[keepArchiveId, key], ct).ConfigureAwait(false);
|
||||
if (holder is null)
|
||||
{
|
||||
await inner.ExecuteAsync(
|
||||
"INSERT INTO sequence_sessions (archive_id, session_key, sequence_id) VALUES ($1, $2, $3) ON CONFLICT (archive_id, session_key) DO NOTHING",
|
||||
[keepArchiveId, key, keep], ct).ConfigureAwait(false);
|
||||
keys++;
|
||||
}
|
||||
else if (holder == drop)
|
||||
{
|
||||
await inner.ExecuteAsync("UPDATE sequence_sessions SET sequence_id = $3 WHERE archive_id = $1 AND session_key = $2",
|
||||
[keepArchiveId, key, keep], ct).ConfigureAwait(false);
|
||||
keys++;
|
||||
}
|
||||
else if (holder != keep)
|
||||
{
|
||||
skipped.Add(key);
|
||||
continue;
|
||||
}
|
||||
await inner.ExecuteAsync("DELETE FROM sequence_sessions WHERE sequence_id = $1 AND session_key = $2", [drop, key], ct).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
// (2) Links, with the agreement reset as SyncService's LinkAsync resets a link it points at another copy.
|
||||
var links = await inner.ExecuteAsync(
|
||||
"UPDATE sync_links SET local_id = $2, base_local_settings = NULL, base_remote_settings = NULL, diff_local_frames = NULL, " +
|
||||
"diff_remote_frames = NULL, diff_local_renders = NULL, diff_remote_renders = NULL, diff_remote_updated_at = NULL, missing_remote = 0, " +
|
||||
"missing_local = 0, exports_to_get = 0, exports_to_get_bytes = 0, exports_to_send = 0, exports_to_send_bytes = 0, " +
|
||||
"conflict_local_settings = NULL, conflict_remote_settings = NULL, conflict_remote = NULL WHERE local_id = $1",
|
||||
[drop, keep], ct).ConfigureAwait(false);
|
||||
|
||||
// (3) Pairs.
|
||||
var pairs = 0;
|
||||
var rows = await inner.ListAsync($"{Select} WHERE local_id = $1 OR other_id = $1 ORDER BY found_at, id", [drop], Map, ct).ConfigureAwait(false);
|
||||
foreach (var row in rows.Where(r => r.Id != exceptCopyId))
|
||||
{
|
||||
var state = row.State == CopyState.Integrated ? CopyState.Linked : row.State;
|
||||
if (row.Kind == CopyKind.LocalServer)
|
||||
{
|
||||
if (await FindRemoteAsync(inner, keep, row.Server!, row.RemoteId!.Value, ct).ConfigureAwait(false) is not null)
|
||||
{
|
||||
await inner.ExecuteAsync("DELETE FROM found_copies WHERE id = $1", [row.Id], ct).ConfigureAwait(false);
|
||||
continue;
|
||||
}
|
||||
await inner.ExecuteAsync(
|
||||
"UPDATE found_copies SET local_id = $2, state = $3, auto_photos = $4, local_frames_version = -1, updated_at = $5 WHERE id = $1",
|
||||
[row.Id, keep, (int)state, false, now], ct).ConfigureAwait(false);
|
||||
pairs++;
|
||||
continue;
|
||||
}
|
||||
var other = row.LocalId == drop ? row.OtherId!.Value : row.LocalId;
|
||||
if (other == keep)
|
||||
{
|
||||
await inner.ExecuteAsync("DELETE FROM found_copies WHERE id = $1", [row.Id], ct).ConfigureAwait(false);
|
||||
continue;
|
||||
}
|
||||
var (low, high) = Order(keep, other);
|
||||
if (await inner.SingleAsync($"{Select} WHERE kind = 1 AND local_id = $1 AND other_id = $2", [low, high], Map, ct).ConfigureAwait(false) is not null)
|
||||
{
|
||||
await inner.ExecuteAsync("DELETE FROM found_copies WHERE id = $1", [row.Id], ct).ConfigureAwait(false);
|
||||
continue;
|
||||
}
|
||||
await inner.ExecuteAsync(
|
||||
"UPDATE found_copies SET local_id = $2, other_id = $3, state = $4, auto_photos = $5, local_frames_version = -1, " +
|
||||
"other_frames_version = -1, updated_at = $6 WHERE id = $1",
|
||||
[row.Id, low, high, (int)state, false, now], ct).ConfigureAwait(false);
|
||||
pairs++;
|
||||
}
|
||||
return new MoveResult(keys, skipped, links, pairs);
|
||||
}, ct);
|
||||
}
|
||||
|
||||
public Task<CopyProbe?> GetProbeAsync(Guid sequenceId, string scope, CancellationToken ct) =>
|
||||
_db.SingleAsync("SELECT sequence_id, scope, frames_version, hashed, probed_at FROM copy_probes WHERE sequence_id = $1 AND scope = $2",
|
||||
[sequenceId, scope], r => new CopyProbe(r.GetGuid(0), r.GetString(1), r.GetInt32(2), r.GetInt32(3), r.GetDateTimeOffset(4)), ct);
|
||||
|
||||
public Task SetProbeAsync(CopyProbe probe, CancellationToken ct)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(probe);
|
||||
return _db.ExecuteAsync(ProbeUpsert, [probe.SequenceId, probe.Scope, probe.FramesVersion, probe.Hashed, probe.ProbedAt], ct);
|
||||
}
|
||||
|
||||
/// <summary>Forgets what was probed in <paramref name="scope"/>: the next detection probes every sequence again (Find matches).</summary>
|
||||
public Task ResetProbesAsync(string scope, CancellationToken ct) =>
|
||||
_db.ExecuteAsync("DELETE FROM copy_probes WHERE scope = $1", [scope], ct);
|
||||
|
||||
/// <summary>
|
||||
/// Local pairs sharing SHA-256 (frames ⋈ frames), tombstoned content (frame_removals ⋈ frames) and, only while the index
|
||||
/// has unhashed frames, size and capture time (frames ⋈ frames), one row per pair, ordered (<see cref="Order"/>).
|
||||
/// </summary>
|
||||
public async Task<IReadOnlyList<LocalOverlap>> LocalOverlapsAsync(CancellationToken ct)
|
||||
{
|
||||
var pairs = new Dictionary<(Guid, Guid), (int Hashes, int Removed, int Unhashed)>();
|
||||
var byHash = await _db.ListAsync(
|
||||
"SELECT a.sequence_id, b.sequence_id, count(DISTINCT a.sha256) FROM frames a " +
|
||||
"JOIN frames b ON b.sha256 = a.sha256 AND b.sequence_id > a.sequence_id " +
|
||||
"WHERE a.sha256 IS NOT NULL AND a.sha256 <> '' GROUP BY a.sequence_id, b.sequence_id",
|
||||
[], Row, ct).ConfigureAwait(false);
|
||||
foreach (var (a, b, n) in byHash) Add(a, b, n, 0, 0);
|
||||
var byRemoval = await _db.ListAsync(
|
||||
"SELECT r.sequence_id, f.sequence_id, count(DISTINCT r.sha256) FROM frame_removals r " +
|
||||
"JOIN frames f ON f.sha256 = r.sha256 AND f.sequence_id <> r.sequence_id GROUP BY r.sequence_id, f.sequence_id",
|
||||
[], Row, ct).ConfigureAwait(false);
|
||||
foreach (var (a, b, n) in byRemoval) Add(a, b, 0, n, 0);
|
||||
var unhashed = await _db.ScalarAsync<long?>("SELECT 1 FROM frames WHERE sha256 IS NULL OR sha256 = '' LIMIT 1", [], ct).ConfigureAwait(false);
|
||||
if (unhashed is not null)
|
||||
{
|
||||
var bySize = await _db.ListAsync(
|
||||
"SELECT a.sequence_id, b.sequence_id, count(*) FROM frames a " +
|
||||
"JOIN frames b ON b.captured_at = a.captured_at AND b.size = a.size AND b.sequence_id > a.sequence_id " +
|
||||
"WHERE a.captured_at IS NOT NULL AND (a.sha256 IS NULL OR a.sha256 = '' OR b.sha256 IS NULL OR b.sha256 = '') " +
|
||||
"GROUP BY a.sequence_id, b.sequence_id",
|
||||
[], Row, ct).ConfigureAwait(false);
|
||||
foreach (var (a, b, n) in bySize) Add(a, b, 0, 0, n);
|
||||
}
|
||||
return [.. pairs.Select(p => new LocalOverlap(p.Key.Item1, p.Key.Item2, p.Value.Hashes, p.Value.Removed, p.Value.Unhashed))
|
||||
.OrderBy(o => o.Low.ToString("D"), StringComparer.Ordinal).ThenBy(o => o.High.ToString("D"), StringComparer.Ordinal)];
|
||||
|
||||
void Add(Guid a, Guid b, int hashes, int removed, int unhashedCount)
|
||||
{
|
||||
var key = Order(a, b);
|
||||
var known = pairs.GetValueOrDefault(key);
|
||||
pairs[key] = (known.Hashes + hashes, known.Removed + removed, known.Unhashed + unhashedCount);
|
||||
}
|
||||
|
||||
static (Guid, Guid, int) Row(DbRow r) => (r.GetGuid(0), r.GetGuid(1), r.GetInt32(2));
|
||||
}
|
||||
|
||||
/// <summary>The download back-references <c>chronos-sync:<remoteId:N></c> of local sequences (sequence_sessions).</summary>
|
||||
public async Task<IReadOnlyList<(Guid SequenceId, Guid RemoteId)>> SyncSessionKeysAsync(CancellationToken ct)
|
||||
{
|
||||
const string prefix = "chronos-sync:";
|
||||
var rows = await _db.ListAsync("SELECT sequence_id, session_key FROM sequence_sessions WHERE session_key LIKE $1 ORDER BY sequence_id, session_key",
|
||||
[prefix + "%"], r => (Sequence: r.GetGuid(0), Key: r.GetString(1)), ct).ConfigureAwait(false);
|
||||
var result = new List<(Guid, Guid)>();
|
||||
foreach (var (sequence, key) in rows)
|
||||
{
|
||||
if (!key.StartsWith(prefix, StringComparison.Ordinal)) continue;
|
||||
if (Guid.TryParseExact(key.AsSpan(prefix.Length), "N", out var remote)) result.Add((sequence, remote));
|
||||
}
|
||||
return [.. result.Distinct()];
|
||||
}
|
||||
|
||||
// ---------------- Helpers ----------------
|
||||
|
||||
private static Task<FoundCopy?> FindRemoteAsync(DbAccess access, Guid localId, string server, Guid remoteId, CancellationToken ct) =>
|
||||
access.SingleAsync($"{Select} WHERE kind = 0 AND local_id = $1 AND server = $2 AND remote_id = $3", [localId, server, remoteId], Map, ct);
|
||||
|
||||
/// <summary>Linked and Integrated rows of the server sequence with another local copy, or of the local copy with another server sequence, become Candidates.</summary>
|
||||
private static Task<int> DemoteAsync(DbAccess access, string server, Guid remoteId, Guid localId, DateTimeOffset now, CancellationToken ct) =>
|
||||
access.ExecuteAsync(
|
||||
"UPDATE found_copies SET state = 0, auto_photos = $4, updated_at = $5 WHERE kind = 0 AND server = $1 AND state IN (2, 4) " +
|
||||
"AND ((remote_id = $2 AND local_id <> $3) OR (local_id = $3 AND remote_id <> $2))",
|
||||
[server, remoteId, localId, false, now], ct);
|
||||
|
||||
private static FoundCopy LinkRow(string server, Guid remoteId, Guid localId, DateTimeOffset now) => new()
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Kind = CopyKind.LocalServer,
|
||||
LocalId = localId,
|
||||
Server = server,
|
||||
RemoteId = remoteId,
|
||||
Evidence = CopyEvidence.Link,
|
||||
State = CopyState.Linked,
|
||||
Fingerprint = "link",
|
||||
FoundAt = now,
|
||||
UpdatedAt = now,
|
||||
};
|
||||
|
||||
private static Task<int> InsertAsync(DbAccess access, FoundCopy c, DateTimeOffset now, CancellationToken ct)
|
||||
{
|
||||
var s = c.Score;
|
||||
return access.ExecuteAsync(
|
||||
$"INSERT INTO found_copies ({Columns}) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, " +
|
||||
"$21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35)",
|
||||
[
|
||||
c.Id, (int)c.Kind, c.LocalId, DbParam.Text(c.Server), c.RemoteId, c.OtherId, (int)c.Evidence, (int)c.State, s.Shared, s.SharedUnhashed,
|
||||
s.SharedRemoved, s.OnlyHere, s.OnlyThere, s.Differs, s.DeletedHere, s.DeletedThere, s.Versions, s.LocalPhotos, s.OtherPhotos,
|
||||
s.Containment, s.Overlap, s.Hints, c.LocalFramesVersion, c.OtherFramesVersion, c.Fingerprint, DbParam.Text(c.AnsweredFingerprint),
|
||||
c.AnsweredShared, c.AutoPhotos, c.JobId, (int?)c.PreviousState, c.RemoteGoneAt, c.RemoteGoneHits,
|
||||
c.FoundAt == default ? now : c.FoundAt, now, c.AnsweredAt,
|
||||
], ct);
|
||||
}
|
||||
|
||||
/// <summary>A local pair in its stored order (its sides swapped when given the other way round); a server pair as given, checked.</summary>
|
||||
private static FoundCopy Normalised(FoundCopy copy)
|
||||
{
|
||||
if (copy.Kind == CopyKind.LocalServer)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(copy.Server) || copy.RemoteId is null || copy.OtherId is not null)
|
||||
throw new ArgumentException("A local↔server pair names a server and its sequence, and no other local sequence.", nameof(copy));
|
||||
return copy;
|
||||
}
|
||||
if (copy.OtherId is not { } other || other == copy.LocalId || copy.Server is not null || copy.RemoteId is not null)
|
||||
throw new ArgumentException("A local pair names two different local sequences and no server.", nameof(copy));
|
||||
var (low, _) = Order(copy.LocalId, other);
|
||||
if (low == copy.LocalId) return copy;
|
||||
var s = copy.Score;
|
||||
return copy with
|
||||
{
|
||||
LocalId = other,
|
||||
OtherId = copy.LocalId,
|
||||
LocalFramesVersion = copy.OtherFramesVersion,
|
||||
OtherFramesVersion = copy.LocalFramesVersion,
|
||||
Score = s with
|
||||
{
|
||||
OnlyHere = s.OnlyThere,
|
||||
OnlyThere = s.OnlyHere,
|
||||
DeletedHere = s.DeletedThere,
|
||||
DeletedThere = s.DeletedHere,
|
||||
LocalPhotos = s.OtherPhotos,
|
||||
OtherPhotos = s.LocalPhotos,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
private static FoundCopy Map(DbRow r)
|
||||
{
|
||||
var stored = (CopyState)r.GetInt32(7);
|
||||
var state = (CopyState)r.GetInt32(35);
|
||||
var live = state == stored;
|
||||
return new FoundCopy
|
||||
{
|
||||
Id = r.GetGuid(0),
|
||||
Kind = (CopyKind)r.GetInt32(1),
|
||||
LocalId = r.GetGuid(2),
|
||||
Server = r.GetStringOrNull(3),
|
||||
RemoteId = r.GetGuidOrNull(4),
|
||||
OtherId = r.GetGuidOrNull(5),
|
||||
Evidence = (CopyEvidence)r.GetInt32(6),
|
||||
State = state,
|
||||
Score = new CopyScore(r.GetInt32(8), r.GetInt32(9), r.GetInt32(10), r.GetInt32(11), r.GetInt32(12), r.GetInt32(13), r.GetInt32(14),
|
||||
r.GetInt32(15), r.GetInt32(16), r.GetInt32(17), r.GetInt32(18), r.GetInt32(19), r.GetInt32(20), r.GetInt32(21)),
|
||||
LocalFramesVersion = r.GetInt32(22),
|
||||
OtherFramesVersion = r.GetInt32(23),
|
||||
Fingerprint = r.GetString(24),
|
||||
AnsweredFingerprint = r.GetStringOrNull(25),
|
||||
AnsweredShared = r.GetInt32OrNull(26),
|
||||
AutoPhotos = r.GetBool(27),
|
||||
JobId = live ? r.GetGuidOrNull(28) : null,
|
||||
PreviousState = live && r.GetInt32OrNull(29) is { } previous ? (CopyState)previous : null,
|
||||
RemoteGoneAt = r.GetDateTimeOffsetOrNull(30),
|
||||
RemoteGoneHits = r.GetInt32(31),
|
||||
FoundAt = r.GetDateTimeOffset(32),
|
||||
UpdatedAt = r.GetDateTimeOffset(33),
|
||||
AnsweredAt = r.GetDateTimeOffsetOrNull(34),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Data.Archiving;
|
||||
using Chronos.Data.Jobs;
|
||||
using Chronos.Data.Sync;
|
||||
|
||||
namespace Chronos.Data.Copies;
|
||||
|
||||
/// <summary>
|
||||
/// Matches (owner review 6, #73): two copies of one time-lapse found here and on a server, or twice on this PC; compared,
|
||||
/// integrated, merged, kept apart, linked or unlinked. Every change that moves files is planned first (a dry run), then
|
||||
/// applied by a job that re-plans and refuses a changed plan.
|
||||
/// </summary>
|
||||
public interface ICopyEngine
|
||||
{
|
||||
/// <summary>A detection run found something (new pairs, pairs linked by themselves, kept-apart pairs that ask again).</summary>
|
||||
event Action<CopyFindResult>? Found;
|
||||
|
||||
/// <summary>Every listed pair with the facts of both sides.</summary>
|
||||
Task<IReadOnlyList<FoundCopyView>> ListAsync(CancellationToken ct);
|
||||
|
||||
/// <summary>Looks for matches now: on <paramref name="remote"/>'s server when given, and among this PC's archives always.</summary>
|
||||
Task<CopyFindResult> FindAsync(ISyncRemote? remote, CancellationToken ct);
|
||||
|
||||
/// <summary>Both sides of a pair compared photo by photo, detail by detail, with projects and renders.</summary>
|
||||
Task<CopyReview> CompareAsync(Guid copyId, ISyncRemote? remote, CancellationToken ct);
|
||||
|
||||
Task<IntegratePlan> PlanIntegrateAsync(Guid copyId, ISyncRemote remote, IntegrateChoices choices, CancellationToken ct);
|
||||
|
||||
Task<Job> EnqueueIntegrateAsync(JobEngine engine, IntegratePlan plan, CancellationToken ct);
|
||||
|
||||
/// <summary>The plan of a merge of a local pair; <paramref name="keepId"/> null leaves the kept sequence unchosen unless one is preselected.</summary>
|
||||
Task<MergePlan> PlanMergeAsync(Guid copyId, Guid? keepId, MergeChoices choices, CancellationToken ct);
|
||||
|
||||
Task<Job> EnqueueMergeAsync(JobEngine engine, MergePlan plan, CancellationToken ct);
|
||||
|
||||
Task KeepApartAsync(Guid copyId, CancellationToken ct);
|
||||
|
||||
Task AskAgainAsync(Guid copyId, CancellationToken ct);
|
||||
|
||||
Task LinkAsync(Guid copyId, ISyncRemote remote, CancellationToken ct);
|
||||
|
||||
Task UnlinkAsync(Guid copyId, ISyncRemote? remote, CancellationToken ct);
|
||||
|
||||
/// <summary>The dry run of moving photos of the local copy (by photo key) to its archive trash.</summary>
|
||||
Task<FrameDeletePlan> PlanTrashHereAsync(Guid copyId, IReadOnlyCollection<string> photoKeys, CancellationToken ct);
|
||||
|
||||
/// <summary>Applies <paramref name="plan"/>, refusing photos no longer deleted on the other side; returns the photos moved.</summary>
|
||||
Task<int> TrashHereAsync(Guid copyId, FrameDeletePlan plan, ISyncRemote? remote, CancellationToken ct);
|
||||
|
||||
/// <summary>The server's dry run of moving photos of the server copy (by photo key) to the server's trash.</summary>
|
||||
Task<TrashTherePlan> PlanTrashThereAsync(Guid copyId, ISyncRemote remote, IReadOnlyCollection<string> photoKeys, CancellationToken ct);
|
||||
|
||||
/// <summary>Applies <paramref name="plan"/> on the server at the plan's frames version; returns the photos moved.</summary>
|
||||
Task<int> TrashThereAsync(TrashTherePlan plan, ISyncRemote remote, CancellationToken ct);
|
||||
|
||||
/// <summary>Keeps this PC's sequence of a pair whose server copy was deleted, and stops asking.</summary>
|
||||
Task KeepHereAsync(Guid copyId, CancellationToken ct);
|
||||
|
||||
/// <summary>Linked or integrated pairs with workspace projects at both homes (the Edit picker's twins).</summary>
|
||||
Task<IReadOnlyList<CopyTwin>> TwinsAsync(CancellationToken ct);
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
using Chronos.Data.Sync;
|
||||
|
||||
namespace Chronos.Data.Copies;
|
||||
|
||||
/// <summary>Why Upload all local left a sequence out (owner review 6, Q8).</summary>
|
||||
public enum UploadSkip
|
||||
{
|
||||
/// <summary>In a match nobody answered yet: it may be on the server already.</summary>
|
||||
SuspectedCopy,
|
||||
|
||||
/// <summary>The user kept it apart from a match.</summary>
|
||||
KeptApart,
|
||||
|
||||
/// <summary>It lies in a server's originals archive: it came from a server.</summary>
|
||||
ServerOriginals,
|
||||
|
||||
/// <summary>The server deleted its copy (a 404 for the linked sequence).</summary>
|
||||
DeletedOnServer,
|
||||
|
||||
/// <summary>An Integrate or Merge job holds it, or will.</summary>
|
||||
Busy,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Which local-only sequences Upload all local sends (design §6.4, owner review 6, Q8): suspected copies, kept-apart ones,
|
||||
/// those the server deleted, those an Integrate or Merge holds and those in any server's originals archive are skipped and
|
||||
/// flagged, never uploaded as new server sequences. Pure.
|
||||
/// </summary>
|
||||
public static class UploadAllRule
|
||||
{
|
||||
/// <summary>
|
||||
/// Splits <paramref name="localOnly"/> into the entries to upload and those skipped with the reason.
|
||||
/// <paramref name="copies"/> are every pair of the index (any server, and local pairs); <paramref name="serverOriginalsArchives"/>
|
||||
/// every known server's originals archive (the current one's too); <paramref name="busy"/> the targets of pending or
|
||||
/// running Integrate and MergeSequences jobs. An entry without a local sequence is neither.
|
||||
/// </summary>
|
||||
public static (IReadOnlyList<SyncEntry> Upload, IReadOnlyList<(SyncEntry Entry, UploadSkip Why)> Skipped) Select(
|
||||
IEnumerable<SyncEntry> localOnly, IReadOnlyCollection<FoundCopy> copies, IReadOnlySet<Guid> serverOriginalsArchives,
|
||||
IReadOnlySet<Guid> busy)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(localOnly);
|
||||
ArgumentNullException.ThrowIfNull(copies);
|
||||
ArgumentNullException.ThrowIfNull(serverOriginalsArchives);
|
||||
ArgumentNullException.ThrowIfNull(busy);
|
||||
|
||||
var bySequence = new Dictionary<Guid, List<FoundCopy>>();
|
||||
foreach (var copy in copies)
|
||||
{
|
||||
Add(copy.LocalId, copy);
|
||||
if (copy.OtherId is { } other) Add(other, copy);
|
||||
}
|
||||
|
||||
var upload = new List<SyncEntry>();
|
||||
var skipped = new List<(SyncEntry, UploadSkip)>();
|
||||
foreach (var entry in localOnly)
|
||||
{
|
||||
if (entry.Local is not { } local) continue;
|
||||
var pairs = bySequence.GetValueOrDefault(local.Id) ?? [];
|
||||
UploadSkip? why =
|
||||
busy.Contains(local.Id) || pairs.Any(p => p.State == CopyState.Integrating) ? UploadSkip.Busy
|
||||
: pairs.Any(p => p.Kind == CopyKind.LocalServer && p.RemoteGoneHits >= 1) ? UploadSkip.DeletedOnServer
|
||||
: pairs.Any(p => p.State == CopyState.KeptApart) ? UploadSkip.KeptApart
|
||||
: pairs.Any(p => p.State == CopyState.Candidate) ? UploadSkip.SuspectedCopy
|
||||
: serverOriginalsArchives.Contains(local.ArchiveId) ? UploadSkip.ServerOriginals
|
||||
: null;
|
||||
if (why is { } reason) skipped.Add((entry, reason));
|
||||
else upload.Add(entry);
|
||||
}
|
||||
return (upload, skipped);
|
||||
|
||||
void Add(Guid id, FoundCopy copy)
|
||||
{
|
||||
if (!bySequence.TryGetValue(id, out var list)) bySequence[id] = list = [];
|
||||
list.Add(copy);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -279,7 +279,8 @@ public sealed class JobEngine : IAsyncDisposable
|
||||
var lowest = running.MinBy(r => queue.LevelOf(r.Job.Kind))!;
|
||||
if (queue.LevelOf(lowest.Job.Kind) == JobKindPriority.High) return false;
|
||||
var next = await PeekAsync(queue, lowest, cancellationToken).ConfigureAwait(false);
|
||||
if (next is null || !queue.Interrupts(next.Kind, lowest.Job.Kind)) return false;
|
||||
// A background job (automatic transfers of integrated pairs, owner review 6) waits for the running one instead.
|
||||
if (next is null || next.Priority == JobPriority.Background || !queue.Interrupts(next.Kind, lowest.Job.Kind)) return false;
|
||||
if (!lowest.Yield(next)) return false;
|
||||
Log.Info("jobs", $"{lowest.Job.Kind} job {lowest.Job.Id} yields to {next.Kind} job {next.Id} (priority queue)");
|
||||
return true;
|
||||
|
||||
@@ -25,7 +25,8 @@ public sealed record JobPriorityQueue
|
||||
/// The levels a kind has unless the user changed it: renders, imports and downloads first, and the copy of a project's
|
||||
/// media into the workspace, which Edit waits for (owner review 2, R8), a workspace's local render and the move of the
|
||||
/// workspace folder, which Edit is held for (phase 5c), and the copy of videos into the videos folder, a transfer the user
|
||||
/// waits for like a download (owner review 1, R9); a local render's sending home at the normal level; the long
|
||||
/// waits for like a download (owner review 1, R9), and the integration and merge of two copies of a sequence the user
|
||||
/// started (owner review 6); a local render's sending home at the normal level; the long
|
||||
/// passes that resume anywhere, and the housekeeping of the schedules (backups, clean-ups), last.
|
||||
/// </summary>
|
||||
public static IReadOnlyDictionary<JobKind, JobKindPriority> DefaultLevels { get; } = new Dictionary<JobKind, JobKindPriority>
|
||||
@@ -38,6 +39,8 @@ public sealed record JobPriorityQueue
|
||||
[JobKind.WorkspaceSend] = JobKindPriority.Normal,
|
||||
[JobKind.WorkspaceMove] = JobKindPriority.High,
|
||||
[JobKind.VideoCopy] = JobKindPriority.High,
|
||||
[JobKind.Integrate] = JobKindPriority.High,
|
||||
[JobKind.MergeSequences] = JobKindPriority.High,
|
||||
[JobKind.Verify] = JobKindPriority.Low,
|
||||
[JobKind.Proxies] = JobKindPriority.Low,
|
||||
[JobKind.Backup] = JobKindPriority.Low,
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
-- Found copies (owner review 6, #73): see sqlite/0012_found_copies.sql. Mirrors it.
|
||||
|
||||
CREATE TABLE found_copies (
|
||||
id uuid PRIMARY KEY,
|
||||
kind integer NOT NULL,
|
||||
local_id uuid NOT NULL REFERENCES sequences (id) ON DELETE CASCADE,
|
||||
server text COLLATE "C",
|
||||
remote_id uuid,
|
||||
other_id uuid REFERENCES sequences (id) ON DELETE CASCADE,
|
||||
evidence integer NOT NULL,
|
||||
state integer NOT NULL DEFAULT 0,
|
||||
shared integer NOT NULL DEFAULT 0,
|
||||
shared_unhashed integer NOT NULL DEFAULT 0,
|
||||
shared_removed integer NOT NULL DEFAULT 0,
|
||||
only_here integer NOT NULL DEFAULT 0,
|
||||
only_there integer NOT NULL DEFAULT 0,
|
||||
differs integer NOT NULL DEFAULT 0,
|
||||
deleted_here integer NOT NULL DEFAULT 0,
|
||||
deleted_there integer NOT NULL DEFAULT 0,
|
||||
versions integer NOT NULL DEFAULT 0,
|
||||
local_photos integer NOT NULL DEFAULT 0,
|
||||
other_photos integer NOT NULL DEFAULT 0,
|
||||
containment integer NOT NULL DEFAULT 0,
|
||||
overlap integer NOT NULL DEFAULT 0,
|
||||
hints integer NOT NULL DEFAULT 0,
|
||||
local_frames_version integer NOT NULL DEFAULT 0,
|
||||
other_frames_version integer NOT NULL DEFAULT 0,
|
||||
fingerprint text NOT NULL,
|
||||
answered_fingerprint text,
|
||||
answered_shared integer,
|
||||
auto_photos boolean NOT NULL DEFAULT false,
|
||||
job_id uuid,
|
||||
previous_state integer,
|
||||
remote_gone_at timestamptz,
|
||||
remote_gone_hits integer NOT NULL DEFAULT 0,
|
||||
found_at timestamptz NOT NULL,
|
||||
updated_at timestamptz NOT NULL,
|
||||
answered_at timestamptz,
|
||||
CHECK ((kind = 0 AND server IS NOT NULL AND remote_id IS NOT NULL AND other_id IS NULL)
|
||||
OR (kind = 1 AND server IS NULL AND remote_id IS NULL AND other_id IS NOT NULL AND other_id <> local_id))
|
||||
);
|
||||
CREATE UNIQUE INDEX ux_found_copies_remote ON found_copies (local_id, server, remote_id) WHERE kind = 0;
|
||||
CREATE UNIQUE INDEX ux_found_copies_local ON found_copies (local_id, other_id) WHERE kind = 1;
|
||||
CREATE INDEX ix_found_copies_server ON found_copies (server, remote_id);
|
||||
CREATE INDEX ix_found_copies_other ON found_copies (other_id);
|
||||
CREATE INDEX ix_found_copies_state ON found_copies (state);
|
||||
|
||||
CREATE TABLE copy_probes (
|
||||
sequence_id uuid NOT NULL REFERENCES sequences (id) ON DELETE CASCADE,
|
||||
scope text COLLATE "C" NOT NULL,
|
||||
frames_version integer NOT NULL,
|
||||
hashed integer NOT NULL,
|
||||
probed_at timestamptz NOT NULL,
|
||||
PRIMARY KEY (sequence_id, scope)
|
||||
);
|
||||
|
||||
INSERT INTO found_copies (id, kind, local_id, server, remote_id, evidence, state, fingerprint, found_at, updated_at)
|
||||
SELECT gen_random_uuid(), 0, local_id, server, remote_id, 0, 2, 'link', now(), now()
|
||||
FROM sync_links WHERE local_id IS NOT NULL;
|
||||
@@ -0,0 +1,74 @@
|
||||
-- Found copies (owner review 6, #73): two copies of one time-lapse whose ids differ, a local sequence and a sequence of a
|
||||
-- server (kind 0) or two local sequences of this index (kind 1), with the evidence, the scores of the last comparison, the
|
||||
-- user's answer and, once integrated, the pair's policy. A pair is never two links: sync_links stays the 1:1 per server
|
||||
-- record a sync compares; every link has a row here too (evidence 0, state 2), so a server deletion and the per-link policy
|
||||
-- have a place. Scores are counts and per-mille ratios of the last exact comparison, at the frames versions it read. The
|
||||
-- answered_* columns keep what a "Keep apart" was given, so only a large later change asks again. remote_gone_* record a
|
||||
-- server's 404 for the remote side (two answers on two refreshes before the pair reads "deleted on server"). Local columns
|
||||
-- cascade: a sequence deleted into the trash (or removed by Rebuild, Orphans or Reidentify) takes its pairs along; the
|
||||
-- next detection finds such a pair again as a candidate (DECISIONS). Mirrors postgres/0012_found_copies.sql.
|
||||
|
||||
CREATE TABLE found_copies (
|
||||
id TEXT NOT NULL PRIMARY KEY,
|
||||
kind INTEGER NOT NULL,
|
||||
local_id TEXT NOT NULL REFERENCES sequences (id) ON DELETE CASCADE,
|
||||
server TEXT,
|
||||
remote_id TEXT,
|
||||
other_id TEXT REFERENCES sequences (id) ON DELETE CASCADE,
|
||||
evidence INTEGER NOT NULL,
|
||||
state INTEGER NOT NULL DEFAULT 0,
|
||||
shared INTEGER NOT NULL DEFAULT 0,
|
||||
shared_unhashed INTEGER NOT NULL DEFAULT 0,
|
||||
shared_removed INTEGER NOT NULL DEFAULT 0,
|
||||
only_here INTEGER NOT NULL DEFAULT 0,
|
||||
only_there INTEGER NOT NULL DEFAULT 0,
|
||||
differs INTEGER NOT NULL DEFAULT 0,
|
||||
deleted_here INTEGER NOT NULL DEFAULT 0,
|
||||
deleted_there INTEGER NOT NULL DEFAULT 0,
|
||||
versions INTEGER NOT NULL DEFAULT 0,
|
||||
local_photos INTEGER NOT NULL DEFAULT 0,
|
||||
other_photos INTEGER NOT NULL DEFAULT 0,
|
||||
containment INTEGER NOT NULL DEFAULT 0,
|
||||
overlap INTEGER NOT NULL DEFAULT 0,
|
||||
hints INTEGER NOT NULL DEFAULT 0,
|
||||
local_frames_version INTEGER NOT NULL DEFAULT 0,
|
||||
other_frames_version INTEGER NOT NULL DEFAULT 0,
|
||||
fingerprint TEXT NOT NULL,
|
||||
answered_fingerprint TEXT,
|
||||
answered_shared INTEGER,
|
||||
auto_photos INTEGER NOT NULL DEFAULT 0,
|
||||
job_id TEXT,
|
||||
previous_state INTEGER,
|
||||
remote_gone_at TEXT,
|
||||
remote_gone_hits INTEGER NOT NULL DEFAULT 0,
|
||||
found_at TEXT NOT NULL,
|
||||
updated_at TEXT NOT NULL,
|
||||
answered_at TEXT,
|
||||
CHECK ((kind = 0 AND server IS NOT NULL AND remote_id IS NOT NULL AND other_id IS NULL)
|
||||
OR (kind = 1 AND server IS NULL AND remote_id IS NULL AND other_id IS NOT NULL AND other_id <> local_id))
|
||||
);
|
||||
CREATE UNIQUE INDEX ux_found_copies_remote ON found_copies (local_id, server, remote_id) WHERE kind = 0;
|
||||
CREATE UNIQUE INDEX ux_found_copies_local ON found_copies (local_id, other_id) WHERE kind = 1;
|
||||
CREATE INDEX ix_found_copies_server ON found_copies (server, remote_id);
|
||||
CREATE INDEX ix_found_copies_other ON found_copies (other_id);
|
||||
CREATE INDEX ix_found_copies_state ON found_copies (state);
|
||||
|
||||
-- What detection last sent or compared of each local sequence, per scope (a server key, or '' for this PC's archives):
|
||||
-- a sequence whose frames version and hashed count are unchanged is not probed again.
|
||||
CREATE TABLE copy_probes (
|
||||
sequence_id TEXT NOT NULL REFERENCES sequences (id) ON DELETE CASCADE,
|
||||
scope TEXT NOT NULL,
|
||||
frames_version INTEGER NOT NULL,
|
||||
hashed INTEGER NOT NULL,
|
||||
probed_at TEXT NOT NULL,
|
||||
PRIMARY KEY (sequence_id, scope)
|
||||
);
|
||||
|
||||
-- Every existing link is a linked pair (no score yet: the next comparison fills it). Ids are random v4 UUIDs.
|
||||
INSERT INTO found_copies (id, kind, local_id, server, remote_id, evidence, state, fingerprint, found_at, updated_at)
|
||||
SELECT lower(substr(h, 1, 8) || '-' || substr(h, 9, 4) || '-4' || substr(h, 14, 3) || '-'
|
||||
|| substr('89ab', 1 + (abs(random()) % 4), 1) || substr(h, 18, 3) || '-' || substr(h, 21, 12)),
|
||||
0, local_id, server, remote_id, 0, 2, 'link', ts, ts
|
||||
FROM (SELECT hex(randomblob(16)) AS h, local_id, server, remote_id,
|
||||
strftime('%Y-%m-%dT%H:%M:%f', 'now') || '000Z' AS ts
|
||||
FROM sync_links WHERE local_id IS NOT NULL);
|
||||
@@ -0,0 +1,43 @@
|
||||
using Chronos.Data.Copies;
|
||||
using Chronos.Protocol;
|
||||
|
||||
namespace Chronos.Data.Sync;
|
||||
|
||||
/// <summary>Where a photo of a pair stands (design §4.1); each photo lands in exactly one class.</summary>
|
||||
public enum PhotoClass
|
||||
{
|
||||
Same,
|
||||
SameUnhashed,
|
||||
OnlyHere,
|
||||
OnlyThere,
|
||||
Differs,
|
||||
Converted,
|
||||
DeletedHere,
|
||||
DeletedThere,
|
||||
Versions,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// One side's frame as the comparison reads it (local frames, or the server's manifest and frames). Unusable: the frame is
|
||||
/// flagged Missing or Corrupt (it holds nothing; the other side's copy repairs it).
|
||||
/// </summary>
|
||||
public sealed record CopyPhotoInput(Guid FrameId, int Index, string FileName, string? Sha256, long Size, DateTime? CapturedAt, bool Unusable);
|
||||
|
||||
/// <summary>One side of a comparison: its frames and its tombstones.</summary>
|
||||
public sealed record CopySideInput(IReadOnlyList<CopyPhotoInput> Photos, IReadOnlyList<RemovedPhotoDto> Removed);
|
||||
|
||||
/// <summary>
|
||||
/// A compared photo. Key: canonical SHA-256, or "u:<size>:<capture ms ticks>" while unhashed. Occurrences count
|
||||
/// the copies of the photo inside each side; Bytes is its size on the side that holds it (Differs: here's).
|
||||
/// </summary>
|
||||
public sealed record ComparedPhoto(PhotoClass Class, string Key, CopyPhotoInput? Here, CopyPhotoInput? There,
|
||||
int HereOccurrences, int ThereOccurrences, long Bytes, bool RepairsHere = false, bool RepairsThere = false);
|
||||
|
||||
/// <summary>The count and bytes of one class on each side.</summary>
|
||||
public sealed record PhotoClassTotal(PhotoClass Class, int Count, long HereBytes, long ThereBytes);
|
||||
|
||||
/// <summary>The outcome of comparing two sides photo by photo.</summary>
|
||||
public sealed record CopyComparisonResult(IReadOnlyList<ComparedPhoto> Photos, IReadOnlyList<PhotoClassTotal> Totals, CopyScore Score)
|
||||
{
|
||||
public IEnumerable<ComparedPhoto> Of(PhotoClass c) => Photos.Where(p => p.Class == c);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Text.Json;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Data.Copies;
|
||||
using Chronos.Data.Repositories;
|
||||
|
||||
namespace Chronos.Data.Sync;
|
||||
@@ -47,7 +48,8 @@ internal sealed class SyncLinkStore(ChronosDatabase db)
|
||||
/// Moves every link of <paramref name="from"/> to <paramref name="to"/> in one transaction (owner review 5, #66: an address
|
||||
/// key becomes the server's id key). Where <paramref name="to"/> already links the same server sequence, or the same local
|
||||
/// copy, the row compared last (<see cref="SyncLink.SyncedAt"/>, never compared counting oldest) is kept and the other
|
||||
/// deleted: link rows are recomputed by the next comparison, so nothing is lost.
|
||||
/// deleted: link rows are recomputed by the next comparison, so nothing is lost. The server's found copies and probes move
|
||||
/// in the same transaction (<see cref="FoundCopyStore.RekeyAsync"/>), the pair of the surviving link winning a clash.
|
||||
/// </summary>
|
||||
public async Task<(int Moved, int Dropped)> RekeyAsync(string from, string to, CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -59,7 +61,7 @@ internal sealed class SyncLinkStore(ChronosDatabase db)
|
||||
var inner = new DbAccess(session);
|
||||
var old = await inner.ListAsync($"SELECT {Columns} FROM sync_links WHERE server = $1 ORDER BY remote_id", [from], Map, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
if (old.Count == 0) return (0, 0);
|
||||
var surviving = new HashSet<Guid>();
|
||||
var current = (await inner.ListAsync($"SELECT {Columns} FROM sync_links WHERE server = $1 ORDER BY remote_id", [to], Map, cancellationToken)
|
||||
.ConfigureAwait(false)).ToList();
|
||||
var (moved, dropped) = (0, 0);
|
||||
@@ -81,8 +83,11 @@ internal sealed class SyncLinkStore(ChronosDatabase db)
|
||||
await inner.ExecuteAsync("UPDATE sync_links SET server = $3 WHERE server = $1 AND remote_id = $2", [from, link.RemoteId, to], cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
current.Add(link with { Server = to });
|
||||
surviving.Add(link.RemoteId);
|
||||
moved++;
|
||||
}
|
||||
// The pairs and probes of the server move with its links, in this transaction (owner review 6, #73).
|
||||
await new FoundCopyStore(db).RekeyAsync(session, from, to, surviving, cancellationToken).ConfigureAwait(false);
|
||||
return (moved, dropped);
|
||||
}, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Data.Copies;
|
||||
|
||||
namespace Chronos.Data.Sync;
|
||||
|
||||
@@ -172,7 +173,9 @@ public sealed record SyncSnapshot(string Server, IReadOnlyList<SyncEntry> Entrie
|
||||
/// <param name="AutoSyncSettings">Send and take settings changed on one side only (Server.html "Sync projects automatically").</param>
|
||||
/// <param name="KeepProxiesOffline">Keep the proxy caches of server sequences this PC opened with proxies up to date.</param>
|
||||
/// <param name="CanEdit">The account may change server sequences; without it this PC's edits are never sent.</param>
|
||||
public sealed record SyncPolicy(bool AutoSyncSettings = true, bool KeepProxiesOffline = false, bool CanEdit = true);
|
||||
/// <param name="Linking">What a refresh does with a match it finds (Settings › Server › Link matches, owner review 6, Q1).</param>
|
||||
public sealed record SyncPolicy(bool AutoSyncSettings = true, bool KeepProxiesOffline = false, bool CanEdit = true,
|
||||
CopyLinking Linking = CopyLinking.AskAlways);
|
||||
|
||||
/// <summary>
|
||||
/// A conflict could not be settled as the user chose because one side changed again after it was shown; the
|
||||
|
||||
@@ -92,6 +92,36 @@ public interface ISyncRemote : IDisposable
|
||||
/// then fail every render of them. A remote that cannot say reads this Chronos's.
|
||||
/// </summary>
|
||||
Task<int> SettingsFormatAsync(CancellationToken cancellationToken) => Task.FromResult(Core.Project.ProjectSettings.CurrentVersion);
|
||||
|
||||
/// <summary>
|
||||
/// The capabilities the server announces (<see cref="ServerInfo.Capabilities"/>, names of <see cref="ServerCapabilities"/>).
|
||||
/// A remote that cannot say announces none: callers take the path of an older server.
|
||||
/// </summary>
|
||||
Task<IReadOnlySet<string>> CapabilitiesAsync(CancellationToken cancellationToken) =>
|
||||
Task.FromResult<IReadOnlySet<string>>(new HashSet<string>(StringComparer.Ordinal));
|
||||
|
||||
/// <summary>
|
||||
/// Which server sequences hold sampled photos of local sequences (owner review 6, #73; <see cref="ServerCapabilities.PhotoLookup"/>).
|
||||
/// See <see cref="ChronosClient.LookupPhotosAsync"/>. A remote without the call throws <see cref="NotSupportedException"/>.
|
||||
/// </summary>
|
||||
Task<PhotoLookupResponse> LookupPhotosAsync(PhotoLookupRequest request, CancellationToken cancellationToken) => throw new NotSupportedException();
|
||||
|
||||
/// <summary>
|
||||
/// Upload of one original into <paramref name="sequenceId"/> that the server files there even when another of its
|
||||
/// sequences holds the photo (<see cref="StartUploadRequest.IntoTarget"/>, owner review 6; <see cref="ServerCapabilities.UploadInto"/>).
|
||||
/// Null when the target deleted the photo. A remote without the call throws <see cref="NotSupportedException"/>.
|
||||
/// </summary>
|
||||
Task<CompleteUploadResponse?> UploadFileIntoAsync(string path, Guid sequenceId, string sha256, DateTime? capturedAt,
|
||||
CancellationToken cancellationToken) => throw new NotSupportedException();
|
||||
|
||||
/// <summary>
|
||||
/// Moves frames of a server sequence into the server's trash, or with <see cref="FrameDeleteRequest.DryRun"/> answers the
|
||||
/// plan only (owner review 6, #73). A 409 <see cref="ChronosApiException"/> means the frames moved since
|
||||
/// <see cref="FrameDeleteRequest.ExpectedFramesVersion"/>, 403 that the account may not. A remote without the call throws
|
||||
/// <see cref="NotSupportedException"/>.
|
||||
/// </summary>
|
||||
Task<FrameDeleteResultDto> DeleteFramesAsync(Guid sequenceId, FrameDeleteRequest request, CancellationToken cancellationToken) =>
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -141,6 +171,34 @@ public sealed class ChronosSyncRemote(ChronosClient client, bool ownsClient, str
|
||||
/// <summary>The settings format the server announced, and when it was read (a <see cref="System.Diagnostics.Stopwatch"/> timestamp).</summary>
|
||||
private sealed record KnownFormat(int Format, long Read);
|
||||
|
||||
private Task<IReadOnlySet<string>>? _capabilities;
|
||||
|
||||
/// <summary>Read from <c>server/info</c> once per remote (a remote lives for one session; an update of the server ends it).</summary>
|
||||
public Task<IReadOnlySet<string>> CapabilitiesAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var known = Volatile.Read(ref _capabilities);
|
||||
if (known is { IsFaulted: false, IsCanceled: false }) return known;
|
||||
var read = ReadCapabilitiesAsync(cancellationToken);
|
||||
Volatile.Write(ref _capabilities, read);
|
||||
return read;
|
||||
}
|
||||
|
||||
private async Task<IReadOnlySet<string>> ReadCapabilitiesAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var info = await client.GetInfoAsync(cancellationToken).ConfigureAwait(false);
|
||||
return new HashSet<string>(info.Capabilities ?? [], StringComparer.Ordinal);
|
||||
}
|
||||
|
||||
public Task<PhotoLookupResponse> LookupPhotosAsync(PhotoLookupRequest request, CancellationToken cancellationToken) =>
|
||||
client.LookupPhotosAsync(request, cancellationToken);
|
||||
|
||||
public Task<CompleteUploadResponse?> UploadFileIntoAsync(string path, Guid sequenceId, string sha256, DateTime? capturedAt,
|
||||
CancellationToken cancellationToken) =>
|
||||
client.UploadFileIntoAsync(path, sequenceId, capturedAt, sha256, null, cancellationToken);
|
||||
|
||||
public Task<FrameDeleteResultDto> DeleteFramesAsync(Guid sequenceId, FrameDeleteRequest request, CancellationToken cancellationToken) =>
|
||||
client.DeleteFramesAsync(sequenceId, request, cancellationToken);
|
||||
|
||||
public string Server { get; } = string.IsNullOrWhiteSpace(server) ? SyncService.ServerKey(client.BaseAddress) : server;
|
||||
|
||||
public async Task<IReadOnlyList<SequenceDto>> ListSequencesAsync(CancellationToken cancellationToken)
|
||||
|
||||
@@ -278,6 +278,25 @@ public sealed class ChronosClient : IDisposable
|
||||
}, ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asks which server sequences hold sampled photos of local sequences (<c>POST /api/v1/photos/lookup</c>, owner review 6,
|
||||
/// #73; servers announcing <see cref="ServerCapabilities.PhotoLookup"/>). At most
|
||||
/// <see cref="PhotoLookupRequest.MaxProbes"/> probes and <see cref="PhotoLookupRequest.MaxItems"/> items; 413
|
||||
/// <c>too_many</c> beyond.
|
||||
/// </summary>
|
||||
public Task<PhotoLookupResponse> LookupPhotosAsync(PhotoLookupRequest request, CancellationToken ct = default) =>
|
||||
RetryAsync(() => SendAsync(HttpMethod.Post, "api/v1/photos/lookup", request, ProtocolJson.Default.PhotoLookupRequest,
|
||||
ProtocolJson.Default.PhotoLookupResponse, ct), ct);
|
||||
|
||||
/// <summary>
|
||||
/// Moves frames of a server sequence into the server's trash (<c>POST /api/v1/sequences/{id}/frames/delete</c>, the Delete
|
||||
/// right, owner or admin), each leaving a tombstone; <see cref="FrameDeleteRequest.DryRun"/> answers the plan only. A
|
||||
/// moved <see cref="FrameDeleteRequest.ExpectedFramesVersion"/> is refused (409).
|
||||
/// </summary>
|
||||
public Task<FrameDeleteResultDto> DeleteFramesAsync(Guid sequenceId, FrameDeleteRequest request, CancellationToken ct = default) =>
|
||||
SendAsync(HttpMethod.Post, $"api/v1/sequences/{sequenceId}/frames/delete", request, ProtocolJson.Default.FrameDeleteRequest,
|
||||
ProtocolJson.Default.FrameDeleteResultDto, ct);
|
||||
|
||||
// ---------------- Uploads ----------------
|
||||
|
||||
/// <summary>
|
||||
@@ -286,19 +305,38 @@ public sealed class ChronosClient : IDisposable
|
||||
/// deleted from the target sequence, before the upload or while it was on its way (owner review 2, R6). Transient
|
||||
/// failures retry with exponential backoff.
|
||||
/// </summary>
|
||||
public async Task<CompleteUploadResponse?> UploadFileAsync(
|
||||
public Task<CompleteUploadResponse?> UploadFileAsync(
|
||||
string path,
|
||||
Guid? sequenceId,
|
||||
DateTime? capturedAt,
|
||||
string? sessionKey = null,
|
||||
string? knownSha256 = null,
|
||||
IProgress<UploadProgress>? progress = null,
|
||||
CancellationToken ct = default)
|
||||
CancellationToken ct = default) =>
|
||||
UploadAsync(path, sequenceId, capturedAt, sessionKey, knownSha256, intoTarget: false, progress, ct);
|
||||
|
||||
/// <summary>
|
||||
/// Uploads one file into <paramref name="sequenceId"/> with <see cref="StartUploadRequest.IntoTarget"/> (owner review 6,
|
||||
/// #73; servers announcing <see cref="ServerCapabilities.UploadInto"/>): a photo another sequence of the server holds is
|
||||
/// copied into the target by the server, no bytes on the wire. Returns the target's frame; null when the target deleted
|
||||
/// the photo (deleted photos stay deleted).
|
||||
/// </summary>
|
||||
public Task<CompleteUploadResponse?> UploadFileIntoAsync(
|
||||
string path,
|
||||
Guid sequenceId,
|
||||
DateTime? capturedAt,
|
||||
string? knownSha256 = null,
|
||||
IProgress<UploadProgress>? progress = null,
|
||||
CancellationToken ct = default) =>
|
||||
UploadAsync(path, sequenceId, capturedAt, null, knownSha256, intoTarget: true, progress, ct);
|
||||
|
||||
private async Task<CompleteUploadResponse?> UploadAsync(string path, Guid? sequenceId, DateTime? capturedAt, string? sessionKey,
|
||||
string? knownSha256, bool intoTarget, IProgress<UploadProgress>? progress, CancellationToken ct)
|
||||
{
|
||||
var info = new FileInfo(path);
|
||||
var sha = knownSha256 ?? await HashFileAsync(path, ct).ConfigureAwait(false);
|
||||
var start = await RetryAsync(() => SendAsync(HttpMethod.Post, "api/v1/uploads",
|
||||
new StartUploadRequest(sequenceId, info.Name, info.Length, sha, capturedAt, sessionKey),
|
||||
new StartUploadRequest(sequenceId, info.Name, info.Length, sha, capturedAt, sessionKey, IntoTarget: intoTarget),
|
||||
ProtocolJson.Default.StartUploadRequest, ProtocolJson.Default.StartUploadResponse, ct), ct).ConfigureAwait(false);
|
||||
if (start.AlreadyExists)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
namespace Chronos.Protocol;
|
||||
|
||||
/// <summary>
|
||||
/// One local sequence's sample for <c>POST /api/v1/photos/lookup</c> (owner review 6, #73): up to 64 SHA-256 (lower-case
|
||||
/// hex), up to 64 unhashed photos, and its back-reference key.
|
||||
/// </summary>
|
||||
public sealed record PhotoProbe(string Key, IReadOnlyList<string> Sha256, IReadOnlyList<PhotoKeyDto>? Unhashed = null, string? SessionKey = null);
|
||||
|
||||
/// <summary>An unhashed photo, told apart by size and capture time to the millisecond.</summary>
|
||||
public sealed record PhotoKeyDto(long Size, DateTime CapturedAt);
|
||||
|
||||
/// <summary>At most 200 probes and 20,000 items (hashes + unhashed keys + session keys) in all; 413 <c>too_many</c> beyond.</summary>
|
||||
public sealed record PhotoLookupRequest(IReadOnlyList<PhotoProbe> Probes)
|
||||
{
|
||||
/// <summary>The most probes one request may carry.</summary>
|
||||
public const int MaxProbes = 200;
|
||||
|
||||
/// <summary>The most items (hashes, unhashed keys and session keys) one request may carry.</summary>
|
||||
public const int MaxItems = 20_000;
|
||||
|
||||
/// <summary>The items the request carries, as the limit counts them.</summary>
|
||||
public int CountItems() => Probes.Sum(p => (p.Sha256?.Count ?? 0) + (p.Unhashed?.Count ?? 0) + (p.SessionKey is null ? 0 : 1));
|
||||
}
|
||||
|
||||
/// <summary>The answer of a lookup: one result per probe, in the request's order.</summary>
|
||||
public sealed record PhotoLookupResponse(IReadOnlyList<ProbeResult> Results);
|
||||
|
||||
/// <summary>The server sequences a probe hit.</summary>
|
||||
public sealed record ProbeResult(string Key, IReadOnlyList<PhotoLookupHit> Hits);
|
||||
|
||||
/// <summary>
|
||||
/// Hashes: distinct probe hashes the sequence holds in a frame; Removed: distinct probe hashes it tombstoned (deleted, or
|
||||
/// replaced by a conversion); Unhashed: probe keys a frame of it matches by size and capture time to the millisecond;
|
||||
/// SessionKey: the sequence is filed under the probe's session key.
|
||||
/// </summary>
|
||||
public sealed record PhotoLookupHit(Guid SequenceId, int Hashes, int Removed, int Unhashed, bool SessionKey);
|
||||
@@ -48,6 +48,18 @@ public static class ServerCapabilities
|
||||
/// its renders into its videos folder. Without it a client lists only its own videos.
|
||||
/// </summary>
|
||||
public const string Videos = "videos";
|
||||
|
||||
/// <summary>
|
||||
/// The server answers <c>POST /api/v1/photos/lookup</c> (owner review 6, #73): which of its sequences hold sampled photos
|
||||
/// of a client's sequences, by SHA-256, tombstone, size and capture time, or session key.
|
||||
/// </summary>
|
||||
public const string PhotoLookup = "photo-lookup";
|
||||
|
||||
/// <summary>
|
||||
/// The server files an upload into its target even when another sequence holds the photo
|
||||
/// (<see cref="StartUploadRequest.IntoTarget"/>, owner review 6, #73).
|
||||
/// </summary>
|
||||
public const string UploadInto = "upload-into";
|
||||
}
|
||||
|
||||
/// <summary><c>GET /health</c>.</summary>
|
||||
|
||||
@@ -77,6 +77,12 @@ namespace Chronos.Protocol;
|
||||
[JsonSerializable(typeof(RemovedPhotoDto))]
|
||||
[JsonSerializable(typeof(FrameDeleteRequest))]
|
||||
[JsonSerializable(typeof(FrameDeleteResultDto))]
|
||||
[JsonSerializable(typeof(PhotoProbe))]
|
||||
[JsonSerializable(typeof(PhotoKeyDto))]
|
||||
[JsonSerializable(typeof(PhotoLookupRequest))]
|
||||
[JsonSerializable(typeof(PhotoLookupResponse))]
|
||||
[JsonSerializable(typeof(ProbeResult))]
|
||||
[JsonSerializable(typeof(PhotoLookupHit))]
|
||||
[JsonSerializable(typeof(TrashEntryDto))]
|
||||
[JsonSerializable(typeof(TrashListDto))]
|
||||
[JsonSerializable(typeof(TrashRestoreDto))]
|
||||
|
||||
@@ -6,11 +6,22 @@ namespace Chronos.Protocol;
|
||||
/// from the target sequence is answered the same way, without a frame (owner review 2, R6), unless <see cref="Restore"/>
|
||||
/// asks to file it there again: only an explicit user action sends it (the admin panel's "Upload again"), never sync or a
|
||||
/// watch folder, and the completion repeats it (<c>complete?restore=true</c>). Filing it drops the photo's tombstone.
|
||||
/// <para>
|
||||
/// <see cref="IntoTarget"/> (owner review 6, #73; capability <see cref="ServerCapabilities.UploadInto"/>) files the photo into
|
||||
/// <see cref="SequenceId"/> even when another sequence of the served archive holds it: the server copies its own file into
|
||||
/// the target, no bytes on the wire, and answers <see cref="StartUploadResponse.Copied"/>. The caller must own the target,
|
||||
/// be an admin or hold the Edit right; never with <see cref="Restore"/>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public sealed record StartUploadRequest(Guid? SequenceId, string FileName, long Size, string Sha256, DateTime? CapturedAt, string? SessionKey,
|
||||
bool Restore = false);
|
||||
bool Restore = false, bool IntoTarget = false);
|
||||
|
||||
public sealed record StartUploadResponse(Guid? UploadId, int ChunkSize, IReadOnlyList<int> Received, bool AlreadyExists, Guid? FrameId);
|
||||
/// <summary>
|
||||
/// The answer to <c>POST /api/v1/uploads</c>. <see cref="Copied"/>: the server filed the photo into the target from a file it
|
||||
/// held in another sequence (<see cref="StartUploadRequest.IntoTarget"/>); <see cref="FrameId"/> is the new frame.
|
||||
/// </summary>
|
||||
public sealed record StartUploadResponse(Guid? UploadId, int ChunkSize, IReadOnlyList<int> Received, bool AlreadyExists, Guid? FrameId,
|
||||
bool Copied = false);
|
||||
|
||||
/// <summary>Error codes of the frame upload calls that clients act on.</summary>
|
||||
public static class UploadErrors
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
using Chronos.Core.Import;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Data.Archiving;
|
||||
using Chronos.Data.Tests.Infrastructure;
|
||||
using Chronos.Testing;
|
||||
using static Chronos.Data.Tests.Archiving.ArchiveFixture;
|
||||
|
||||
namespace Chronos.Data.Tests.Archiving;
|
||||
|
||||
/// <summary>
|
||||
/// Trash steps run inside the job that holds the sequence (an Integrate or a merge, owner review 6, #73): the job's own hold
|
||||
/// does not make the sequence busy, another job's still does, and a frames version that moved refuses the step.
|
||||
/// </summary>
|
||||
[Category("archive")]
|
||||
public abstract class TrashExceptJobTests(TestContext context) : DatabaseTest(context)
|
||||
{
|
||||
private async Task<ArchiveFixture> FixtureAsync() => Own(await CreateAsync(Context, database: await NewOptionsAsync(multiConnection: true)));
|
||||
|
||||
private static async Task<Sequence> UploadedAsync(ArchiveFixture fx, int count, string session, int seed)
|
||||
{
|
||||
Guid? id = null;
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var (path, size, sha) = fx.Stage(Start.AddSeconds(10 * i), seed + i);
|
||||
var result = await fx.Service.Ingest.CommitAsync(new IngestRequest(fx.Archive.Id, id, null, id is null ? session : null, path, $"IMG_{i + 1:0000}.JPG",
|
||||
size, sha, null, null), fx.Ct);
|
||||
id = result.SequenceId;
|
||||
}
|
||||
return (await fx.Db.Sequences.GetAsync(id!.Value))!;
|
||||
}
|
||||
|
||||
private static async Task<Job> RunningAsync(ArchiveFixture fx, JobKind kind, params Guid[] targets)
|
||||
{
|
||||
var job = new Job
|
||||
{
|
||||
Id = Guid.CreateVersion7(),
|
||||
Kind = kind,
|
||||
TargetIds = targets,
|
||||
State = JobState.Running,
|
||||
NodeId = "test#0",
|
||||
Created = DateTimeOffset.UtcNow,
|
||||
Started = DateTimeOffset.UtcNow,
|
||||
};
|
||||
await fx.Db.Jobs.EnqueueAsync(job);
|
||||
return job;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task APhotoTrashStepInsideItsOwnJobIsNotBusyAnotherJobsTargetIs()
|
||||
{
|
||||
var fx = await FixtureAsync();
|
||||
var sequence = await UploadedAsync(fx, 3, "upload-1", 100);
|
||||
var frames = await fx.Db.Frames.ListBySequenceAsync(sequence.Id);
|
||||
var trash = fx.Service.FrameTrash;
|
||||
var integrate = await RunningAsync(fx, JobKind.Integrate, sequence.Id);
|
||||
|
||||
Assert.SequenceEqual([FrameDeleteBlock.Busy], (await trash.PlanDeleteAsync(sequence.Id, [frames[0].Id], sequence.FramesVersion, fx.Ct)).Blocked);
|
||||
var plan = await trash.PlanDeleteAsync(sequence.Id, [frames[0].Id], sequence.FramesVersion, fx.Ct, exceptJob: integrate.Id);
|
||||
Assert.True(plan.CanDelete, string.Join(", ", plan.Blocked));
|
||||
// The re-plan of the deletion itself must not count the job either.
|
||||
await Assert.ThrowsAsync<StaleDeletePlanException>(() => trash.DeleteAsync(plan, "alberto", null, fx.Ct));
|
||||
var result = await trash.DeleteAsync(plan, "alberto", null, fx.Ct, exceptJob: integrate.Id);
|
||||
Assert.Equal(sequence.Id, result.Sequence.Id);
|
||||
Assert.Count(2, await fx.Db.Frames.ListBySequenceAsync(sequence.Id));
|
||||
|
||||
await RunningAsync(fx, JobKind.Render, sequence.Id);
|
||||
var now = (await fx.Db.Sequences.GetAsync(sequence.Id))!;
|
||||
var held = await trash.PlanDeleteAsync(sequence.Id, [frames[1].Id], now.FramesVersion, fx.Ct, exceptJob: integrate.Id);
|
||||
Assert.SequenceEqual([FrameDeleteBlock.Busy], held.Blocked);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ASequenceTrashStepInsideItsOwnJobIsNotBusyAnotherJobsTargetIs()
|
||||
{
|
||||
var fx = await FixtureAsync();
|
||||
var keep = await UploadedAsync(fx, 2, "upload-1", 100);
|
||||
var drop = await UploadedAsync(fx, 2, "upload-2", 200);
|
||||
var merge = await RunningAsync(fx, JobKind.MergeSequences, keep.Id, drop.Id);
|
||||
|
||||
Assert.Equal(DeleteBlock.Busy, (await fx.Service.Trash.PlanAsync([drop.Id], null, fx.Ct)).Blocked.Single().Reason);
|
||||
var plan = await fx.Service.Trash.PlanAsync([drop.Id], null, fx.Ct, exceptJob: merge.Id);
|
||||
Assert.Empty(plan.Blocked);
|
||||
// Revalidated without the job's own hold too.
|
||||
await Assert.ThrowsAsync<StaleDeletePlanException>(() => fx.Service.Trash.DeleteAsync(plan, null, null, fx.Ct));
|
||||
Assert.NotNull(await fx.Db.Sequences.GetAsync(drop.Id));
|
||||
var entries = await fx.Service.Trash.DeleteAsync(plan, "alberto", null, fx.Ct, exceptJob: merge.Id,
|
||||
expectedFramesVersions: new Dictionary<Guid, int> { [drop.Id] = drop.FramesVersion });
|
||||
Assert.Count(1, entries);
|
||||
Assert.Null(await fx.Db.Sequences.GetAsync(drop.Id));
|
||||
|
||||
await RunningAsync(fx, JobKind.Render, keep.Id);
|
||||
Assert.Equal(DeleteBlock.Busy, (await fx.Service.Trash.PlanAsync([keep.Id], null, fx.Ct, exceptJob: merge.Id)).Blocked.Single().Reason);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AFramesVersionThatMovedRefusesTheStepUnderItsLeaseAndNothingMoves()
|
||||
{
|
||||
var fx = await FixtureAsync();
|
||||
var drop = await UploadedAsync(fx, 2, "upload-1", 100);
|
||||
var plan = await fx.Service.Trash.PlanAsync([drop.Id], null, fx.Ct);
|
||||
var folder = fx.Paths.Sequence(drop.Folder).Folder;
|
||||
|
||||
// A photo added since the version the caller verified.
|
||||
await Assert.ThrowsAsync<StaleDeletePlanException>(() => fx.Service.Trash.DeleteAsync(plan, null, null, fx.Ct,
|
||||
expectedFramesVersions: new Dictionary<Guid, int> { [drop.Id] = drop.FramesVersion - 1 }));
|
||||
Assert.NotNull(await fx.Db.Sequences.GetAsync(drop.Id));
|
||||
Assert.True(Directory.Exists(folder));
|
||||
|
||||
// A sequence the map does not name is not checked; the one it names at its version goes.
|
||||
var entries = await fx.Service.Trash.DeleteAsync(plan, null, null, fx.Ct,
|
||||
expectedFramesVersions: new Dictionary<Guid, int> { [Guid.CreateVersion7()] = 99, [drop.Id] = drop.FramesVersion });
|
||||
Assert.Count(1, entries);
|
||||
Assert.False(Directory.Exists(folder));
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class SqliteTrashExceptJobTests(TestContext context) : TrashExceptJobTests(context)
|
||||
{
|
||||
protected override Backend Backend => Backend.SqliteFile;
|
||||
}
|
||||
|
||||
[RequiresEnvironment(PgTestServer.Variable)]
|
||||
public sealed class PostgresTrashExceptJobTests(TestContext context) : TrashExceptJobTests(context)
|
||||
{
|
||||
protected override Backend Backend => Backend.Postgres;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
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]"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,355 @@
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Data.Copies;
|
||||
using Chronos.Data.Sync;
|
||||
using Chronos.Data.Tests.Infrastructure;
|
||||
using Chronos.Testing;
|
||||
|
||||
namespace Chronos.Data.Tests.Copies;
|
||||
|
||||
/// <summary>The found copies store (owner review 6, #73, migration 0012): pairs, answers, the Integrating backstop, merges and 404s.</summary>
|
||||
[Category("sync")]
|
||||
public abstract class FoundCopyStoreTests(TestContext context) : RepositoryTest(context)
|
||||
{
|
||||
private const string Nas = "https://nas.test:8443";
|
||||
private const string Other = "id:server-b";
|
||||
|
||||
private async Task<(ChronosDatabase Db, Archive Archive, Sequence[] Sequences)> SetupAsync(int count)
|
||||
{
|
||||
var db = await OpenChronosAsync();
|
||||
var archive = TestData.Archive();
|
||||
await db.Archives.UpsertAsync(archive, Ct);
|
||||
var sequences = new Sequence[count];
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
sequences[i] = TestData.Sequence(archive.Id);
|
||||
await db.Sequences.UpsertAsync(sequences[i], Ct);
|
||||
}
|
||||
return (db, archive, sequences);
|
||||
}
|
||||
|
||||
private static FoundCopy Remote(Guid localId, Guid remoteId, string server = Nas, CopyEvidence evidence = CopyEvidence.Hashes) => new()
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Kind = CopyKind.LocalServer,
|
||||
LocalId = localId,
|
||||
Server = server,
|
||||
RemoteId = remoteId,
|
||||
Evidence = evidence,
|
||||
Fingerprint = "f1",
|
||||
};
|
||||
|
||||
private static FoundCopy Local(Guid a, Guid b) => new()
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Kind = CopyKind.LocalLocal,
|
||||
LocalId = a,
|
||||
OtherId = b,
|
||||
Evidence = CopyEvidence.Hashes,
|
||||
Fingerprint = "f1",
|
||||
};
|
||||
|
||||
private static SyncLink Link(string server, Guid remoteId, Guid localId) => new()
|
||||
{
|
||||
Server = server,
|
||||
RemoteId = remoteId,
|
||||
LocalId = localId,
|
||||
Title = "Harbour",
|
||||
RemoteUpdatedAt = TestData.Now,
|
||||
DiffLocalFrames = 3,
|
||||
BaseLocalSettings = 2,
|
||||
MissingRemote = 4,
|
||||
};
|
||||
|
||||
private static CopyAnswer Answer(Guid? job = null, bool? auto = null, string? fingerprint = null, int? shared = null) =>
|
||||
new(fingerprint, shared, job, auto, TestData.Now);
|
||||
|
||||
private async Task<Job> JobAsync(ChronosDatabase db, JobKind kind = JobKind.Integrate)
|
||||
{
|
||||
var job = TestData.Job(kind);
|
||||
await db.Jobs.EnqueueAsync(job, Ct);
|
||||
return job;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AnUpsertUpdatesScoresAndKeepsTheStateAndTheStrongerEvidence()
|
||||
{
|
||||
var (db, _, s) = await SetupAsync(1);
|
||||
var store = new FoundCopyStore(db);
|
||||
var remote = Guid.CreateVersion7();
|
||||
var found = await store.UpsertFoundAsync(Remote(s[0].Id, remote) with { Score = CopyScore.None with { Shared = 3 } }, Ct);
|
||||
Assert.Equal((CopyState.Candidate, CopyEvidence.Hashes, 3), (found.State, found.Evidence, found.Score.Shared));
|
||||
Assert.True(await store.SetStateAsync(found.Id, CopyState.Candidate, CopyState.KeptApart, Answer(fingerprint: "f1", shared: 3), Ct));
|
||||
|
||||
var again = await store.UpsertFoundAsync(Remote(s[0].Id, remote, evidence: CopyEvidence.SizeAndTime) with
|
||||
{
|
||||
Score = CopyScore.None with { Shared = 5 },
|
||||
Fingerprint = "f2",
|
||||
LocalFramesVersion = 7,
|
||||
}, Ct);
|
||||
Assert.Equal(found.Id, again.Id);
|
||||
Assert.Equal((CopyState.KeptApart, CopyEvidence.Hashes, 5, "f2", 7), (again.State, again.Evidence, again.Score.Shared, again.Fingerprint, again.LocalFramesVersion));
|
||||
Assert.Equal(("f1", (int?)3), (again.AnsweredFingerprint, again.AnsweredShared));
|
||||
Assert.Count(1, await store.ListAsync(Ct));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ALocalPairIsStoredOnceInOrder()
|
||||
{
|
||||
var (db, _, s) = await SetupAsync(2);
|
||||
var store = new FoundCopyStore(db);
|
||||
var (low, high) = FoundCopyStore.Order(s[0].Id, s[1].Id);
|
||||
var stored = await store.UpsertFoundAsync(Local(high, low) with { LocalFramesVersion = 1, OtherFramesVersion = 2 }, Ct);
|
||||
Assert.Equal((low, (Guid?)high), (stored.LocalId, stored.OtherId));
|
||||
// The sides swap with the ids.
|
||||
Assert.Equal((2, 1), (stored.LocalFramesVersion, stored.OtherFramesVersion));
|
||||
var same = await store.UpsertFoundAsync(Local(low, high), Ct);
|
||||
Assert.Equal(stored.Id, same.Id);
|
||||
Assert.Equal(stored.Id, (await store.FindLocalAsync(high, low, Ct))!.Id);
|
||||
Assert.Count(1, await store.ListByLocalAsync(high, Ct));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task SetStateIsACompareAndSetAndIntegratingKeepsWhereItCameFrom()
|
||||
{
|
||||
var (db, _, s) = await SetupAsync(1);
|
||||
var store = new FoundCopyStore(db);
|
||||
var row = await store.UpsertFoundAsync(Remote(s[0].Id, Guid.CreateVersion7()), Ct);
|
||||
Assert.False(await store.SetStateAsync(row.Id, CopyState.Linked, CopyState.KeptApart, null, Ct));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => store.SetStateAsync(row.Id, null, CopyState.Integrating, Answer(), Ct));
|
||||
Assert.False(await store.SetStateAsync(Guid.NewGuid(), null, CopyState.KeptApart, null, Ct));
|
||||
|
||||
var job = await JobAsync(db);
|
||||
Assert.True(await store.SetStateAsync(row.Id, CopyState.Candidate, CopyState.Integrating, Answer(job.Id), Ct));
|
||||
var integrating = (await store.GetAsync(row.Id, Ct))!;
|
||||
Assert.Equal((CopyState.Integrating, (CopyState?)CopyState.Candidate, (Guid?)job.Id), (integrating.State, integrating.PreviousState, integrating.JobId));
|
||||
|
||||
Assert.True(await store.SetStateAsync(row.Id, CopyState.Integrating, CopyState.Integrated, Answer(auto: true), Ct));
|
||||
var done = (await store.GetAsync(row.Id, Ct))!;
|
||||
Assert.Equal((CopyState.Integrated, (CopyState?)null, (Guid?)null, true), (done.State, done.PreviousState, done.JobId, done.AutoPhotos));
|
||||
// Auto photos hold only while Integrated.
|
||||
Assert.True(await store.SetStateAsync(row.Id, null, CopyState.Linked, null, Ct));
|
||||
Assert.False((await store.GetAsync(row.Id, Ct))!.AutoPhotos);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AnIntegratingRowWhoseJobFailedOrWasCancelledReadsAsItsPreviousState()
|
||||
{
|
||||
var (db, _, s) = await SetupAsync(2);
|
||||
var store = new FoundCopyStore(db);
|
||||
foreach (var (sequence, end) in new[] { (s[0], JobState.Failed), (s[1], JobState.Cancelled) })
|
||||
{
|
||||
var row = await store.UpsertFoundAsync(Remote(sequence.Id, Guid.CreateVersion7()), Ct);
|
||||
Assert.True(await store.SetStateAsync(row.Id, null, CopyState.KeptApart, Answer(fingerprint: "f1"), Ct));
|
||||
var job = await JobAsync(db);
|
||||
Assert.True(await store.SetStateAsync(row.Id, CopyState.KeptApart, CopyState.Integrating, Answer(job.Id), Ct));
|
||||
Assert.Equal(CopyState.Integrating, (await store.GetAsync(row.Id, Ct))!.State);
|
||||
|
||||
await db.Jobs.SetStateAsync(job.Id, end, null, Ct);
|
||||
var read = (await store.GetAsync(row.Id, Ct))!;
|
||||
Assert.Equal((CopyState.KeptApart, (Guid?)null, (CopyState?)null), (read.State, read.JobId, read.PreviousState));
|
||||
// The compare-and-set sees the state it reads as.
|
||||
Assert.False(await store.SetStateAsync(row.Id, CopyState.Integrating, CopyState.Integrated, null, Ct));
|
||||
Assert.True(await store.SetStateAsync(row.Id, CopyState.KeptApart, CopyState.Candidate, null, Ct));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task PairsGoWithTheirSequenceAndSurviveItsUpsert()
|
||||
{
|
||||
var (db, _, s) = await SetupAsync(3);
|
||||
var store = new FoundCopyStore(db);
|
||||
await store.UpsertFoundAsync(Remote(s[0].Id, Guid.CreateVersion7()), Ct);
|
||||
await store.UpsertFoundAsync(Local(s[0].Id, s[1].Id), Ct);
|
||||
await store.UpsertFoundAsync(Local(s[1].Id, s[2].Id), Ct);
|
||||
await store.SetProbeAsync(new CopyProbe(s[0].Id, Nas, 1, 1, TestData.Now), Ct);
|
||||
|
||||
// A Rebuild writes the sequence row again: its pairs stay.
|
||||
await db.Sequences.UpsertAsync(s[0] with { Title = "Harbour" }, Ct);
|
||||
Assert.Count(3, await store.ListAsync(Ct));
|
||||
|
||||
Assert.True(await db.Sequences.DeleteAsync(s[0].Id, Ct));
|
||||
var left = await store.ListAsync(Ct);
|
||||
Assert.Count(1, left);
|
||||
Assert.True(left[0].Names(s[1].Id) && left[0].Names(s[2].Id));
|
||||
Assert.Null(await store.GetProbeAsync(s[0].Id, Nas, Ct));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task EnsureLinkedPromotesACandidateAndDemotesTheRowsTheLinkNoLongerBacks()
|
||||
{
|
||||
var (db, _, s) = await SetupAsync(2);
|
||||
var store = new FoundCopyStore(db);
|
||||
var (r1, r2) = (Guid.CreateVersion7(), Guid.CreateVersion7());
|
||||
var candidate = await store.UpsertFoundAsync(Remote(s[0].Id, r1), Ct);
|
||||
var linked = await store.EnsureLinkedAsync(Nas, r1, s[0].Id, Ct);
|
||||
Assert.Equal(candidate.Id, linked.Id);
|
||||
Assert.Equal((CopyState.Linked, CopyEvidence.Hashes), (linked.State, linked.Evidence));
|
||||
var other = await store.EnsureLinkedAsync(Other, r1, s[0].Id, Ct);
|
||||
Assert.Equal((CopyState.Linked, CopyEvidence.Link, "link"), (other.State, other.Evidence, other.Fingerprint));
|
||||
|
||||
// The link is pointed at another local copy: the old pair is a candidate again; the other server's stays.
|
||||
var moved = await store.EnsureLinkedAsync(Nas, r1, s[1].Id, Ct);
|
||||
Assert.Equal(CopyState.Linked, moved.State);
|
||||
Assert.Equal(CopyState.Candidate, (await store.GetAsync(linked.Id, Ct))!.State);
|
||||
Assert.Equal(CopyState.Linked, (await store.GetAsync(other.Id, Ct))!.State);
|
||||
|
||||
// The local copy is linked to another server sequence: the same.
|
||||
await store.EnsureLinkedAsync(Nas, r2, s[1].Id, Ct);
|
||||
Assert.Equal(CopyState.Candidate, (await store.GetAsync(moved.Id, Ct))!.State);
|
||||
Assert.Count(4, await store.ListAsync(Ct));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task A404CountsOncePerRefreshAndDeletesTheCandidatesOfThatRemote()
|
||||
{
|
||||
var (db, _, s) = await SetupAsync(2);
|
||||
var store = new FoundCopyStore(db);
|
||||
var remote = Guid.CreateVersion7();
|
||||
// An observation-only link has no pair: nothing happens.
|
||||
await store.MarkRemoteGoneAsync(Nas, remote, null, Guid.NewGuid(), TestData.Now, Ct);
|
||||
Assert.Empty(await store.ListAsync(Ct));
|
||||
|
||||
var candidate = await store.UpsertFoundAsync(Remote(s[1].Id, remote), Ct);
|
||||
var (first, second) = (Guid.NewGuid(), Guid.NewGuid());
|
||||
await store.MarkRemoteGoneAsync(Nas, remote, s[0].Id, first, TestData.Now, Ct);
|
||||
await store.MarkRemoteGoneAsync(Nas, remote, s[0].Id, first, TestData.Now.AddMinutes(1), Ct);
|
||||
var row = (await store.FindRemoteAsync(s[0].Id, Nas, remote, Ct))!;
|
||||
Assert.Equal((1, (DateTimeOffset?)TestData.Now, CopyEvidence.Link, false), (row.RemoteGoneHits, row.RemoteGoneAt, row.Evidence, row.RemoteGone));
|
||||
Assert.Null(await store.GetAsync(candidate.Id, Ct));
|
||||
|
||||
await store.MarkRemoteGoneAsync(Nas, remote, s[0].Id, second, TestData.Now.AddHours(1), Ct);
|
||||
row = (await store.GetAsync(row.Id, Ct))!;
|
||||
Assert.Equal((2, (DateTimeOffset?)TestData.Now, true), (row.RemoteGoneHits, row.RemoteGoneAt, row.RemoteGone));
|
||||
|
||||
await store.ClearRemoteGoneAsync(Nas, remote, Ct);
|
||||
row = (await store.GetAsync(row.Id, Ct))!;
|
||||
Assert.Equal((0, (DateTimeOffset?)null), (row.RemoteGoneHits, row.RemoteGoneAt));
|
||||
// After a clear the same refresh counts again.
|
||||
await store.MarkRemoteGoneAsync(Nas, remote, s[0].Id, second, TestData.Now, Ct);
|
||||
Assert.Equal(1, (await store.GetAsync(row.Id, Ct))!.RemoteGoneHits);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task MoveToKeptMovesKeysLinksAndPairsAndIsIdempotent()
|
||||
{
|
||||
var (db, archive, s) = await SetupAsync(4);
|
||||
var (keep, drop, third, fourth) = (s[0], s[1], s[2], s[3]);
|
||||
var store = new FoundCopyStore(db);
|
||||
var links = new SyncLinkStore(db);
|
||||
var (r1, r2, r3) = (Guid.CreateVersion7(), Guid.CreateVersion7(), Guid.CreateVersion7());
|
||||
await db.Sequences.MapSessionKeyAsync(archive.Id, "upload-a", drop.Id, Ct);
|
||||
await db.Sequences.MapSessionKeyAsync(archive.Id, "upload-c", third.Id, Ct);
|
||||
await links.UpsertAsync(Link(Nas, r1, drop.Id), Ct);
|
||||
var dropLink = await store.EnsureLinkedAsync(Nas, r1, drop.Id, Ct);
|
||||
Assert.True(await store.SetStateAsync(dropLink.Id, CopyState.Linked, CopyState.Integrated, Answer(auto: true), Ct));
|
||||
// keep already pairs with r2: drop's pair of r2 is the clash, deleted.
|
||||
await store.UpsertFoundAsync(Remote(keep.Id, r2), Ct);
|
||||
var clash = await store.UpsertFoundAsync(Remote(drop.Id, r2), Ct);
|
||||
var self = await store.UpsertFoundAsync(Local(keep.Id, drop.Id), Ct);
|
||||
var withThird = await store.UpsertFoundAsync(Local(drop.Id, third.Id), Ct);
|
||||
await store.UpsertFoundAsync(Local(keep.Id, fourth.Id), Ct);
|
||||
var withFourth = await store.UpsertFoundAsync(Local(drop.Id, fourth.Id), Ct);
|
||||
var own = await store.UpsertFoundAsync(Remote(drop.Id, r3, Other), Ct);
|
||||
|
||||
var result = await store.MoveToKeptAsync(drop.Id, keep.Id, archive.Id, ["upload-a", "upload-b", "upload-c"], own.Id, Ct);
|
||||
|
||||
Assert.Equal((2, 1, 2), (result.SessionKeys, result.Links, result.Pairs));
|
||||
Assert.SequenceEqual(["upload-c"], result.SkippedKeys);
|
||||
Assert.Equal(keep.Id, await db.Sequences.FindBySessionKeyAsync(archive.Id, "upload-a", Ct));
|
||||
Assert.Equal(keep.Id, await db.Sequences.FindBySessionKeyAsync(archive.Id, "upload-b", Ct));
|
||||
Assert.Equal(third.Id, await db.Sequences.FindBySessionKeyAsync(archive.Id, "upload-c", Ct));
|
||||
var link = (await links.GetAsync(Nas, r1, Ct))!;
|
||||
Assert.Equal((keep.Id, (int?)null, (int?)null, 0), (link.LocalId!.Value, link.DiffLocalFrames, link.BaseLocalSettings, link.MissingRemote));
|
||||
|
||||
var moved = (await store.GetAsync(dropLink.Id, Ct))!;
|
||||
Assert.Equal((keep.Id, CopyState.Linked, false, -1), (moved.LocalId, moved.State, moved.AutoPhotos, moved.LocalFramesVersion));
|
||||
Assert.Null(await store.GetAsync(clash.Id, Ct));
|
||||
Assert.Null(await store.GetAsync(self.Id, Ct));
|
||||
Assert.Null(await store.GetAsync(withFourth.Id, Ct));
|
||||
var third2 = (await store.GetAsync(withThird.Id, Ct))!;
|
||||
Assert.True(third2.Names(keep.Id) && third2.Names(third.Id));
|
||||
Assert.Equal((-1, -1), (third2.LocalFramesVersion, third2.OtherFramesVersion));
|
||||
Assert.Equal(drop.Id, (await store.GetAsync(own.Id, Ct))!.LocalId);
|
||||
|
||||
var again = await store.MoveToKeptAsync(drop.Id, keep.Id, archive.Id, ["upload-a", "upload-b", "upload-c"], own.Id, Ct);
|
||||
Assert.Equal((0, 0), (again.Links, again.Pairs));
|
||||
Assert.SequenceEqual(["upload-c"], again.SkippedKeys);
|
||||
Assert.Equal(keep.Id, await db.Sequences.FindBySessionKeyAsync(archive.Id, "upload-a", Ct));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task MoveToKeptIsRefusedBeforeAnyChangeWhenBothAreLinkedOnOneServer()
|
||||
{
|
||||
var (db, archive, s) = await SetupAsync(2);
|
||||
var (keep, drop) = (s[0], s[1]);
|
||||
var store = new FoundCopyStore(db);
|
||||
var links = new SyncLinkStore(db);
|
||||
await db.Sequences.MapSessionKeyAsync(archive.Id, "upload-a", drop.Id, Ct);
|
||||
await links.UpsertAsync(Link(Nas, Guid.CreateVersion7(), keep.Id), Ct);
|
||||
var dropRemote = Guid.CreateVersion7();
|
||||
await links.UpsertAsync(Link(Nas, dropRemote, drop.Id), Ct);
|
||||
var pair = await store.UpsertFoundAsync(Local(keep.Id, drop.Id), Ct);
|
||||
|
||||
await Assert.ThrowsAsync<CopyLinkTakenException>(() => store.MoveToKeptAsync(drop.Id, keep.Id, archive.Id, ["upload-a"], null, Ct));
|
||||
Assert.Equal(drop.Id, await db.Sequences.FindBySessionKeyAsync(archive.Id, "upload-a", Ct));
|
||||
Assert.Equal(drop.Id, (await links.GetAsync(Nas, dropRemote, Ct))!.LocalId);
|
||||
Assert.NotNull(await store.GetAsync(pair.Id, Ct));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => store.MoveToKeptAsync(keep.Id, keep.Id, archive.Id, [], null, Ct));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task LocalOverlapsCountHashesTombstonesAndSizeAndTime()
|
||||
{
|
||||
var (db, _, s) = await SetupAsync(4);
|
||||
var store = new FoundCopyStore(db);
|
||||
// s0 and s1 share frames 1 and 2 by hash (TestData.Frame's hash is its index's).
|
||||
foreach (var i in new[] { 1, 2, 3 }) await db.Frames.InsertAsync(TestData.Frame(s[0].Id, i), Ct);
|
||||
foreach (var i in new[] { 1, 2, 4 }) await db.Frames.InsertAsync(TestData.Frame(s[1].Id, i), Ct);
|
||||
// s2 tombstoned frame 3 of s0.
|
||||
await db.FrameRemovals.SyncSequenceAsync(s[2].Id, [new FrameRemoval(s[2].Id, TestData.Frame(s[0].Id, 3).Sha256!, null, RemovalReason.Deleted, TestData.Now)], Ct);
|
||||
Assert.Empty((await store.LocalOverlapsAsync(Ct)).Where(o => o.SharedUnhashed > 0));
|
||||
|
||||
// s3 holds an unhashed frame of s1's size and capture time.
|
||||
var unhashed = TestData.Frame(s[3].Id, 4) with { Sha256 = null };
|
||||
await db.Frames.InsertAsync(unhashed, Ct);
|
||||
var overlaps = (await store.LocalOverlapsAsync(Ct)).ToDictionary(o => (o.Low, o.High));
|
||||
Assert.Equal(3, overlaps.Count);
|
||||
Assert.Equal((2, 0, 0), Counts(overlaps[FoundCopyStore.Order(s[0].Id, s[1].Id)]));
|
||||
Assert.Equal((0, 1, 0), Counts(overlaps[FoundCopyStore.Order(s[0].Id, s[2].Id)]));
|
||||
Assert.Equal((0, 0, 1), Counts(overlaps[FoundCopyStore.Order(s[1].Id, s[3].Id)]));
|
||||
foreach (var o in overlaps.Values) Assert.True(string.CompareOrdinal(o.Low.ToString("D"), o.High.ToString("D")) < 0);
|
||||
|
||||
static (int, int, int) Counts(LocalOverlap o) => (o.SharedHashes, o.SharedRemoved, o.SharedUnhashed);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ProbesAndSyncSessionKeysRoundTrip()
|
||||
{
|
||||
var (db, archive, s) = await SetupAsync(2);
|
||||
var store = new FoundCopyStore(db);
|
||||
await store.SetProbeAsync(new CopyProbe(s[0].Id, Nas, 1, 1, TestData.Now), Ct);
|
||||
await store.SetProbeAsync(new CopyProbe(s[0].Id, Nas, 2, 5, TestData.Now.AddMinutes(1)), Ct);
|
||||
await store.SetProbeAsync(new CopyProbe(s[0].Id, string.Empty, 9, 9, TestData.Now), Ct);
|
||||
Assert.Equal(new CopyProbe(s[0].Id, Nas, 2, 5, TestData.Now.AddMinutes(1)), await store.GetProbeAsync(s[0].Id, Nas, Ct));
|
||||
await store.ResetProbesAsync(Nas, Ct);
|
||||
Assert.Null(await store.GetProbeAsync(s[0].Id, Nas, Ct));
|
||||
Assert.NotNull(await store.GetProbeAsync(s[0].Id, string.Empty, Ct));
|
||||
|
||||
var remote = Guid.CreateVersion7();
|
||||
await db.Sequences.MapSessionKeyAsync(archive.Id, $"chronos-sync:{remote:N}", s[1].Id, Ct);
|
||||
await db.Sequences.MapSessionKeyAsync(archive.Id, "chronos-sync:not-a-guid", s[1].Id, Ct);
|
||||
await db.Sequences.MapSessionKeyAsync(archive.Id, "upload-1", s[0].Id, Ct);
|
||||
Assert.SequenceEqual([(s[1].Id, remote)], await store.SyncSessionKeysAsync(Ct));
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class SqliteFoundCopyStoreTests(TestContext context) : FoundCopyStoreTests(context)
|
||||
{
|
||||
protected override Backend Backend => Backend.SqliteMemory;
|
||||
}
|
||||
|
||||
[RequiresEnvironment(PgTestServer.Variable)]
|
||||
public sealed class PostgresFoundCopyStoreTests(TestContext context) : FoundCopyStoreTests(context)
|
||||
{
|
||||
protected override Backend Backend => Backend.Postgres;
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Data.Copies;
|
||||
using Chronos.Data.Sync;
|
||||
using Chronos.Data.Tests.Infrastructure;
|
||||
using Chronos.Testing;
|
||||
|
||||
namespace Chronos.Data.Tests.Copies;
|
||||
|
||||
/// <summary>Upload all local (owner review 6, Q8): suspected, kept-apart, deleted, busy and server-born sequences stay here.</summary>
|
||||
[Category("sync")]
|
||||
public sealed class UploadAllRuleTests
|
||||
{
|
||||
private const string Nas = "https://nas.test:8443";
|
||||
|
||||
private static readonly Guid Archive = Guid.CreateVersion7();
|
||||
|
||||
private static SyncEntry Entry(Guid? archiveId = null) =>
|
||||
new(TestData.Sequence(archiveId ?? Archive) with { FrameCount = 3 }, null, SyncStatus.LocalOnly);
|
||||
|
||||
private static FoundCopy Remote(Guid localId, CopyState state, int goneHits = 0) => new()
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Kind = CopyKind.LocalServer,
|
||||
LocalId = localId,
|
||||
Server = Nas,
|
||||
RemoteId = Guid.CreateVersion7(),
|
||||
Evidence = CopyEvidence.Hashes,
|
||||
State = state,
|
||||
Fingerprint = "f",
|
||||
RemoteGoneHits = goneHits,
|
||||
};
|
||||
|
||||
private static FoundCopy Local(Guid a, Guid b, CopyState state) => new()
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Kind = CopyKind.LocalLocal,
|
||||
LocalId = a,
|
||||
OtherId = b,
|
||||
Evidence = CopyEvidence.Hashes,
|
||||
State = state,
|
||||
Fingerprint = "f",
|
||||
};
|
||||
|
||||
[Test]
|
||||
public void APlainLocalSequenceUploads()
|
||||
{
|
||||
var plain = Entry();
|
||||
var linked = Entry();
|
||||
var (upload, skipped) = UploadAllRule.Select([plain, linked], [Remote(linked.Local!.Id, CopyState.Linked)], new HashSet<Guid>(), new HashSet<Guid>());
|
||||
Assert.SequenceEqual([plain.Local!.Id, linked.Local!.Id], upload.Select(e => e.Local!.Id));
|
||||
Assert.Empty(skipped);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EachReasonKeepsTheSequenceHereWithItsReason()
|
||||
{
|
||||
var (suspected, keptApart, other, gone, busy, integrating, born) = (Entry(), Entry(), Entry(), Entry(), Entry(), Entry(), Entry(Guid.CreateVersion7()));
|
||||
FoundCopy[] copies =
|
||||
[
|
||||
Remote(suspected.Local!.Id, CopyState.Candidate),
|
||||
// A local pair names its second sequence too.
|
||||
Local(other.Local!.Id, keptApart.Local!.Id, CopyState.KeptApart),
|
||||
// One 404 is enough to stay here: it is not uploaded as a new server sequence.
|
||||
Remote(gone.Local!.Id, CopyState.Linked, goneHits: 1),
|
||||
Remote(integrating.Local!.Id, CopyState.Integrating),
|
||||
];
|
||||
var (upload, skipped) = UploadAllRule.Select([suspected, keptApart, other, gone, busy, integrating, born], copies,
|
||||
new HashSet<Guid> { born.Local!.ArchiveId }, new HashSet<Guid> { busy.Local!.Id });
|
||||
|
||||
Assert.Empty(upload);
|
||||
var why = skipped.ToDictionary(s => s.Entry.Local!.Id, s => s.Why);
|
||||
Assert.Equal(UploadSkip.SuspectedCopy, why[suspected.Local.Id]);
|
||||
Assert.Equal(UploadSkip.KeptApart, why[keptApart.Local.Id]);
|
||||
Assert.Equal(UploadSkip.KeptApart, why[other.Local.Id]);
|
||||
Assert.Equal(UploadSkip.DeletedOnServer, why[gone.Local.Id]);
|
||||
Assert.Equal(UploadSkip.Busy, why[busy.Local.Id]);
|
||||
Assert.Equal(UploadSkip.Busy, why[integrating.Local.Id]);
|
||||
Assert.Equal(UploadSkip.ServerOriginals, why[born.Local.Id]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BusyComesFirstAndAnEntryWithoutALocalSequenceIsNeither()
|
||||
{
|
||||
var entry = Entry();
|
||||
var serverOnly = new SyncEntry(null, new SyncLink { Server = Nas, RemoteId = Guid.CreateVersion7(), Title = "Harbour" }, SyncStatus.RemoteOnly);
|
||||
var (upload, skipped) = UploadAllRule.Select([entry, serverOnly], [Remote(entry.Local!.Id, CopyState.Candidate, goneHits: 2)],
|
||||
new HashSet<Guid> { Archive }, new HashSet<Guid> { entry.Local.Id });
|
||||
Assert.Empty(upload);
|
||||
Assert.Equal((entry.Local.Id, UploadSkip.Busy), (skipped.Single().Entry.Local!.Id, skipped.Single().Why));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using Chronos.Core.IO;
|
||||
using Chronos.Core.Project;
|
||||
using Chronos.Data.Copies;
|
||||
using Chronos.Data.Homes;
|
||||
using Chronos.Data.Projects;
|
||||
using Chronos.Data.Sync;
|
||||
@@ -202,6 +203,105 @@ public abstract class HomeRekeyLinkTests(TestContext context) : RepositoryTest(c
|
||||
Assert.Count(1, await store.ListAsync(HomeFixtures.Other, Ct));
|
||||
Assert.Empty(await store.ListAsync(HomeFixtures.Nas, Ct));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TheMatchesAndProbesOfAnAliasMoveWithItsLinks()
|
||||
{
|
||||
var db = await OpenChronosAsync();
|
||||
var (linked, found) = await TwoSequencesAsync(db);
|
||||
var store = new SyncLinkStore(db);
|
||||
var copies = new FoundCopyStore(db);
|
||||
var (r1, r2) = (Guid.CreateVersion7(), Guid.CreateVersion7());
|
||||
await store.UpsertAsync(Link(HomeFixtures.Nas, r1, linked, TestData.Now), Ct);
|
||||
await copies.EnsureLinkedAsync(HomeFixtures.Nas, r1, linked, Ct);
|
||||
await copies.UpsertFoundAsync(Candidate(HomeFixtures.Nas, r2, found), Ct);
|
||||
await copies.SetProbeAsync(new CopyProbe(found, HomeFixtures.Nas, 3, 3, TestData.Now), Ct);
|
||||
|
||||
var migration = new HomeLayoutMigration(new HomeLayoutOptions { DataDirectory = Context.CreateTempDirectory("data"), Database = db });
|
||||
var result = await migration.RekeyAsync(Id, [HomeFixtures.Nas, HomeFixtures.NasByIp], Ct);
|
||||
|
||||
Assert.Equal((1, 0), (result.LinksMoved, result.LinksDropped));
|
||||
var key = ServerIdentity.IdKey(Id);
|
||||
Assert.Empty(await copies.ListByServerAsync(HomeFixtures.Nas, Ct));
|
||||
var moved = await copies.ListByServerAsync(key, Ct);
|
||||
Assert.Count(2, moved);
|
||||
Assert.Equal(CopyState.Linked, moved.Single(c => c.RemoteId == r1).State);
|
||||
Assert.Equal(CopyState.Candidate, moved.Single(c => c.RemoteId == r2).State);
|
||||
Assert.Null(await copies.GetProbeAsync(found, HomeFixtures.Nas, Ct));
|
||||
Assert.Equal(3, (await copies.GetProbeAsync(found, key, Ct))!.FramesVersion);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task OnAClashThePairOfTheSurvivingLinkWinsElseTheHigherState()
|
||||
{
|
||||
var db = await OpenChronosAsync();
|
||||
var (linked, found) = await TwoSequencesAsync(db);
|
||||
var key = ServerIdentity.IdKey(Id);
|
||||
var store = new SyncLinkStore(db);
|
||||
var copies = new FoundCopyStore(db);
|
||||
var (r1, r2) = (Guid.CreateVersion7(), Guid.CreateVersion7());
|
||||
// The same link under both keys: the one compared last (the alias's) survives, and so does its pair, though the pair
|
||||
// under the id is further on.
|
||||
await store.UpsertAsync(Link(HomeFixtures.Nas, r1, linked, TestData.Now), Ct);
|
||||
await store.UpsertAsync(Link(key, r1, linked, TestData.Now.AddHours(-1)), Ct);
|
||||
var aliasPair = await copies.EnsureLinkedAsync(HomeFixtures.Nas, r1, linked, Ct);
|
||||
var idPair = await copies.EnsureLinkedAsync(key, r1, linked, Ct);
|
||||
Assert.True(await copies.SetStateAsync(idPair.Id, CopyState.Linked, CopyState.Integrated, new CopyAnswer(null, null, null, true, TestData.Now), Ct));
|
||||
// A match without a link under both keys: the answered one wins over the newer candidate.
|
||||
var keptApart = await copies.UpsertFoundAsync(Candidate(HomeFixtures.Nas, r2, found), Ct);
|
||||
Assert.True(await copies.SetStateAsync(keptApart.Id, CopyState.Candidate, CopyState.KeptApart, new CopyAnswer("f", 4, null, null, TestData.Now), Ct));
|
||||
var candidate = await copies.UpsertFoundAsync(Candidate(key, r2, found), Ct);
|
||||
await copies.SetProbeAsync(new CopyProbe(found, HomeFixtures.Nas, 1, 1, TestData.Now), Ct);
|
||||
await copies.SetProbeAsync(new CopyProbe(found, key, 2, 2, TestData.Now), Ct);
|
||||
|
||||
var (moved, dropped) = await store.RekeyAsync(HomeFixtures.Nas, key, Ct);
|
||||
|
||||
Assert.Equal((1, 1), (moved, dropped));
|
||||
var rows = await copies.ListByServerAsync(key, Ct);
|
||||
Assert.Count(2, rows);
|
||||
var pair = rows.Single(c => c.RemoteId == r1);
|
||||
Assert.Equal(aliasPair.Id, pair.Id);
|
||||
Assert.Equal(CopyState.Linked, pair.State);
|
||||
var match = rows.Single(c => c.RemoteId == r2);
|
||||
Assert.Equal(keptApart.Id, match.Id);
|
||||
Assert.NotEqual(candidate.Id, match.Id);
|
||||
Assert.Equal(CopyState.KeptApart, match.State);
|
||||
Assert.Empty(await copies.ListByServerAsync(HomeFixtures.Nas, Ct));
|
||||
Assert.Equal(2, (await copies.GetProbeAsync(found, key, Ct))!.FramesVersion);
|
||||
Assert.Null(await copies.GetProbeAsync(found, HomeFixtures.Nas, Ct));
|
||||
}
|
||||
|
||||
private async Task<(Guid Linked, Guid Found)> TwoSequencesAsync(ChronosDatabase db)
|
||||
{
|
||||
var archive = TestData.Archive();
|
||||
await db.Archives.UpsertAsync(archive, Ct);
|
||||
var linked = TestData.Sequence(archive.Id);
|
||||
var found = TestData.Sequence(archive.Id);
|
||||
await db.Sequences.UpsertAsync(linked, Ct);
|
||||
await db.Sequences.UpsertAsync(found, Ct);
|
||||
return (linked.Id, found.Id);
|
||||
}
|
||||
|
||||
private static SyncLink Link(string server, Guid remoteId, Guid localId, DateTimeOffset synced) => new()
|
||||
{
|
||||
Server = server,
|
||||
RemoteId = remoteId,
|
||||
LocalId = localId,
|
||||
Title = "Harbour",
|
||||
RemoteUpdatedAt = TestData.Now,
|
||||
SyncedAt = synced,
|
||||
};
|
||||
|
||||
private static FoundCopy Candidate(string server, Guid remoteId, Guid localId) => new()
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Kind = CopyKind.LocalServer,
|
||||
LocalId = localId,
|
||||
Server = server,
|
||||
RemoteId = remoteId,
|
||||
Evidence = CopyEvidence.Hashes,
|
||||
Fingerprint = "f",
|
||||
};
|
||||
}
|
||||
|
||||
public sealed class SqliteHomeRekeyLinkTests(TestContext context) : HomeRekeyLinkTests(context)
|
||||
|
||||
@@ -462,6 +462,34 @@ public sealed class JobEngineTests(TestContext context)
|
||||
foreach (var id in new[] { analysing.Id, followUp.Id, drawing.Id, other.Id }) await WaitForStateAsync(db, id, JobState.Done, TimeSpan.FromSeconds(10));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ABackgroundJobNeverInterruptsEvenAtAHigherLevel()
|
||||
{
|
||||
// Owner review 6 (#73): an Integrate queued by itself at the end of a sync is High but Background; it waits for the
|
||||
// running job instead of pausing it.
|
||||
await using var db = await OpenAsync();
|
||||
var release = new SemaphoreSlim(0);
|
||||
var scan = new GatedHandler(JobKind.Scan, release);
|
||||
var download = new GatedHandler(JobKind.Download, release);
|
||||
var queue = new JobPriorityQueue { Enabled = true };
|
||||
Assert.True(queue.Interrupts(JobKind.Download, JobKind.Scan));
|
||||
await using var engine = new JobEngine(db, [scan, download],
|
||||
new JobEngineOptions { WorkerId = "pc", PollInterval = TimeSpan.FromMilliseconds(50), PriorityQueue = () => queue });
|
||||
await engine.StartAsync();
|
||||
var scanning = await engine.EnqueueAsync(JobKind.Scan, []);
|
||||
await UntilAsync(() => Volatile.Read(ref scan.Running) == 1, "the scan runs");
|
||||
var downloading = await engine.EnqueueAsync(JobKind.Download, [], priority: JobPriority.Background);
|
||||
await Task.Delay(400);
|
||||
Assert.Equal((1, 0), (Volatile.Read(ref scan.Running), Volatile.Read(ref download.Started)));
|
||||
Assert.Equal(JobState.Running, (await db.Jobs.GetAsync(scanning.Id))!.State);
|
||||
Assert.False(await engine.ReviewAsync(context.Cancellation));
|
||||
|
||||
release.Release(10);
|
||||
await WaitForStateAsync(db, scanning.Id, JobState.Done, TimeSpan.FromSeconds(10));
|
||||
await WaitForStateAsync(db, downloading.Id, JobState.Done, TimeSpan.FromSeconds(10));
|
||||
Assert.Equal(1, Volatile.Read(ref scan.Started));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task RequeueingAYieldedJobLeavesPausesAndOtherNodesAlone()
|
||||
{
|
||||
|
||||
@@ -15,6 +15,8 @@ public sealed class JobWireTests
|
||||
[Case(JobKind.WorkspaceSend, 22, "workspace-send")]
|
||||
[Case(JobKind.WorkspaceMove, 23, "workspace-move")]
|
||||
[Case(JobKind.VideoCopy, 24, "video-copy")]
|
||||
[Case(JobKind.Integrate, 25, "integrate")]
|
||||
[Case(JobKind.MergeSequences, 26, "merge-sequences")]
|
||||
public void TheWorkspaceJobsKeepTheirValueAndName(JobKind kind, int value, string name)
|
||||
{
|
||||
Assert.Equal(value, (int)kind);
|
||||
@@ -40,6 +42,9 @@ public sealed class JobWireTests
|
||||
[Case(JobStep.CopyOriginal, 13, "copy-original")]
|
||||
[Case(JobStep.FollowUps, 22, "follow-ups")]
|
||||
[Case(JobStep.Process, 23, "process")]
|
||||
[Case(JobStep.Details, 24, "details")]
|
||||
[Case(JobStep.Projects, 25, "projects")]
|
||||
[Case(JobStep.Trash, 26, "trash")]
|
||||
public void StepsKeepTheirValueAndName(JobStep step, int value, string name)
|
||||
{
|
||||
Assert.Equal(value, (int)step);
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
using Chronos.Data.Migrations;
|
||||
using Chronos.Data.Tests.Infrastructure;
|
||||
using Chronos.Testing;
|
||||
|
||||
namespace Chronos.Data.Tests.Migrations;
|
||||
|
||||
/// <summary>Migration 0012 (owner review 6, #73): found copies beside the links, every existing link a linked pair.</summary>
|
||||
public abstract class FoundCopiesMigrationTests(TestContext context) : RepositoryTest(context)
|
||||
{
|
||||
[Test]
|
||||
public async Task EveryLinkWithALocalSequenceBecomesOneLinkedPair()
|
||||
{
|
||||
var chronos = await OpenChronosAsync();
|
||||
var database = chronos.Database;
|
||||
var all = MigrationRunner.Load(Dialect);
|
||||
Assert.Equal(12, all.Single(m => m.Name == "found_copies").Version);
|
||||
|
||||
var archive = TestData.Archive();
|
||||
await chronos.Archives.UpsertAsync(archive, Ct);
|
||||
var first = TestData.Sequence(archive.Id);
|
||||
var second = TestData.Sequence(archive.Id);
|
||||
await chronos.Sequences.UpsertAsync(first, Ct);
|
||||
await chronos.Sequences.UpsertAsync(second, Ct);
|
||||
var (r1, r2, r3) = (Guid.CreateVersion7(), Guid.CreateVersion7(), Guid.CreateVersion7());
|
||||
await using (var session = await database.OpenAsync(Ct))
|
||||
{
|
||||
// Back to an index of 1.1 (schema 11) holding these links, then migrated again.
|
||||
await session.ExecuteAsync("DROP TABLE copy_probes", [], Ct);
|
||||
await session.ExecuteAsync("DROP TABLE found_copies", [], Ct);
|
||||
await session.ExecuteAsync("DELETE FROM schema_migrations WHERE version = 12", [], Ct);
|
||||
await Link(session, "https://nas.test:8443", r1, first.Id);
|
||||
await Link(session, "id:server-b", r2, second.Id);
|
||||
// An observation-only link (a server sequence this PC does not hold) is no pair.
|
||||
await Link(session, "https://nas.test:8443", r3, null);
|
||||
}
|
||||
|
||||
Assert.Equal(all[^1].Version, await MigrationRunner.MigrateAsync(database, Ct));
|
||||
await using var after = await database.OpenAsync(Ct);
|
||||
var rows = await after.QueryListAsync(
|
||||
"SELECT id, kind, local_id, server, remote_id, other_id, evidence, state, fingerprint, auto_photos, remote_gone_hits, found_at FROM found_copies ORDER BY server",
|
||||
[], r => r, Ct);
|
||||
Assert.Equal(2, rows.Count);
|
||||
Assert.Equal(2, rows.Select(r => r.GetGuid(0)).Distinct().Count());
|
||||
foreach (var row in rows)
|
||||
{
|
||||
Assert.NotEqual(Guid.Empty, row.GetGuid(0));
|
||||
Assert.Equal(0, row.GetInt32(1));
|
||||
Assert.True(row.IsNull(5));
|
||||
Assert.Equal(0, row.GetInt32(6));
|
||||
Assert.Equal(2, row.GetInt32(7));
|
||||
Assert.Equal("link", row.GetString(8));
|
||||
Assert.False(row.GetBool(9));
|
||||
Assert.Equal(0, row.GetInt32(10));
|
||||
Assert.True(row.GetDateTimeOffset(11) > DateTimeOffset.UtcNow.AddMinutes(-5));
|
||||
}
|
||||
var pairs = rows.Select(r => (r.GetString(3), r.GetGuid(4), r.GetGuid(2))).ToHashSet();
|
||||
Assert.Contains(("https://nas.test:8443", r1, first.Id), pairs);
|
||||
Assert.Contains(("id:server-b", r2, second.Id), pairs);
|
||||
// The ids are random version 4 UUIDs, in the form the binding writes.
|
||||
foreach (var row in rows) Assert.Equal(4, row.GetGuid(0).Version);
|
||||
// No change to the links.
|
||||
Assert.Equal(3L, await after.ScalarAsync<long>("SELECT count(*) FROM sync_links", [], Ct));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TheCheckRefusesAServerPairWithoutServerAndALocalPairOfOneSequence()
|
||||
{
|
||||
var chronos = await OpenChronosAsync();
|
||||
var archive = TestData.Archive();
|
||||
await chronos.Archives.UpsertAsync(archive, Ct);
|
||||
var sequence = TestData.Sequence(archive.Id);
|
||||
await chronos.Sequences.UpsertAsync(sequence, Ct);
|
||||
await using var session = await chronos.Database.OpenAsync(Ct);
|
||||
const string insert = "INSERT INTO found_copies (id, kind, local_id, server, remote_id, other_id, evidence, fingerprint, found_at, updated_at) " +
|
||||
"VALUES ($1, $2, $3, $4, $5, $6, 2, 'f', $7, $7)";
|
||||
await Assert.ThrowsAsync<DatabaseException>(() => session.ExecuteAsync(insert,
|
||||
[Guid.NewGuid(), 0, sequence.Id, DbParam.Text(null), Guid.CreateVersion7(), (Guid?)null, TestData.Now], Ct));
|
||||
await Assert.ThrowsAsync<DatabaseException>(() => session.ExecuteAsync(insert,
|
||||
[Guid.NewGuid(), 1, sequence.Id, DbParam.Text(null), (Guid?)null, sequence.Id, TestData.Now], Ct));
|
||||
await Assert.ThrowsAsync<DatabaseException>(() => session.ExecuteAsync(insert,
|
||||
[Guid.NewGuid(), 1, sequence.Id, "https://nas.test:8443", (Guid?)null, Guid.CreateVersion7(), TestData.Now], Ct));
|
||||
// A pair names existing sequences: a found copy goes with its sequence.
|
||||
await Assert.ThrowsAsync<DatabaseException>(() => session.ExecuteAsync(insert,
|
||||
[Guid.NewGuid(), 0, Guid.CreateVersion7(), "https://nas.test:8443", Guid.CreateVersion7(), (Guid?)null, TestData.Now], Ct));
|
||||
await session.ExecuteAsync(insert, [Guid.NewGuid(), 0, sequence.Id, "https://nas.test:8443", Guid.CreateVersion7(), (Guid?)null, TestData.Now], Ct);
|
||||
Assert.Equal(1L, await session.ScalarAsync<long>("SELECT count(*) FROM found_copies", [], Ct));
|
||||
}
|
||||
|
||||
private static Task<int> Link(IDbSession session, string server, Guid remoteId, Guid? localId) =>
|
||||
session.ExecuteAsync("INSERT INTO sync_links (server, remote_id, local_id, title, remote_updated_at) VALUES ($1, $2, $3, $4, $5)",
|
||||
[server, remoteId, localId, "Remote", TestData.Now], CancellationToken.None);
|
||||
}
|
||||
|
||||
public sealed class SqliteFoundCopiesMigrationTests(TestContext context) : FoundCopiesMigrationTests(context)
|
||||
{
|
||||
protected override Backend Backend => Backend.SqliteMemory;
|
||||
}
|
||||
|
||||
[RequiresEnvironment(PgTestServer.Variable)]
|
||||
public sealed class PostgresFoundCopiesMigrationTests(TestContext context) : FoundCopiesMigrationTests(context)
|
||||
{
|
||||
protected override Backend Backend => Backend.Postgres;
|
||||
}
|
||||
@@ -11,7 +11,7 @@ public abstract class MigrationTests(TestContext context) : RepositoryTest(conte
|
||||
[
|
||||
"archives", "sequences", "frames", "renders", "jobs", "media_cards", "import_history", "users", "tokens",
|
||||
"render_nodes", "settings", "tags", "sequence_tags", "audit_log", "uploads", "schedules", "frame_removals", "projects", "project_versions",
|
||||
"render_copies",
|
||||
"render_copies", "found_copies", "copy_probes",
|
||||
];
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -59,6 +59,134 @@ internal sealed class FakeSyncRemote : ISyncRemote
|
||||
|
||||
public Task<int> SettingsFormatAsync(CancellationToken cancellationToken) => Task.FromResult(SettingsFormat);
|
||||
|
||||
/// <summary>
|
||||
/// The capabilities the server announces (<see cref="ServerCapabilities"/>): none by default, an older server's path
|
||||
/// (owner review 6, #73); tests of the lookup and of uploads into a target opt in.
|
||||
/// </summary>
|
||||
public HashSet<string> Capabilities { get; } = new(StringComparer.Ordinal);
|
||||
|
||||
public Task<IReadOnlySet<string>> CapabilitiesAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
lock (_gate) return Task.FromResult<IReadOnlySet<string>>(new HashSet<string>(Capabilities, StringComparer.Ordinal));
|
||||
}
|
||||
|
||||
/// <summary>Lookup requests so far, as received.</summary>
|
||||
public List<PhotoLookupRequest> Lookups { get; } = [];
|
||||
|
||||
/// <summary>Uploads into a target so far (<see cref="UploadFileIntoAsync"/>), and how many the server filed from a copy it held elsewhere.</summary>
|
||||
public int IntoUploads { get; private set; }
|
||||
|
||||
public int CopiedInto { get; private set; }
|
||||
|
||||
/// <summary>Frame deletions refused with 403, as for an account that is neither the owner nor an admin.</summary>
|
||||
public bool ForbidFrameDeletes { get; set; }
|
||||
|
||||
/// <summary>Frames moved to the server's trash so far, by sequence.</summary>
|
||||
public List<(Guid SequenceId, FakeFrame Frame)> Trashed { get; } = [];
|
||||
|
||||
/// <summary>Files <paramref name="sequence"/> under <paramref name="sessionKey"/>, as an upload with that key would.</summary>
|
||||
public void FileUnder(string sessionKey, FakeSequence sequence)
|
||||
{
|
||||
lock (_gate) _sessions[sessionKey] = sequence;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Like the server (owner review 6, #73): per probe, the sequences holding its hashes in a frame (a sequence it never
|
||||
/// hashed lists none), tombstoning them (by the photo's or its replacement's SHA-256), holding a frame of its unhashed keys
|
||||
/// by size and capture millisecond, or filed under its session key. 404 without <see cref="ServerCapabilities.PhotoLookup"/>,
|
||||
/// 413 beyond the limits.
|
||||
/// </summary>
|
||||
public Task<PhotoLookupResponse> LookupPhotosAsync(PhotoLookupRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
if (!Capabilities.Contains(ServerCapabilities.PhotoLookup)) throw new ChronosApiException(HttpStatusCode.NotFound, new ApiError("not_found", "route"));
|
||||
if (request.Probes.Count > PhotoLookupRequest.MaxProbes || request.CountItems() > PhotoLookupRequest.MaxItems)
|
||||
throw new ChronosApiException(HttpStatusCode.RequestEntityTooLarge, new ApiError("too_many", "probes"));
|
||||
Lookups.Add(request);
|
||||
var results = new List<ProbeResult>();
|
||||
foreach (var probe in request.Probes)
|
||||
{
|
||||
var hashes = probe.Sha256.Select(h => h.ToLowerInvariant()).ToHashSet(StringComparer.Ordinal);
|
||||
var keys = (probe.Unhashed ?? []).Select(k => (k.Size, Ms(k.CapturedAt))).ToHashSet();
|
||||
var filed = probe.SessionKey is { } key && _sessions.TryGetValue(key, out var held) ? held : null;
|
||||
var hits = new List<PhotoLookupHit>();
|
||||
foreach (var sequence in Sequences.Values)
|
||||
{
|
||||
var inFrames = sequence.Unhashed ? 0 : sequence.Frames.Select(f => f.Sha256).Where(hashes.Contains).Distinct(StringComparer.Ordinal).Count();
|
||||
var removed = hashes.Count(h => sequence.Removed.Any(r => r.Sha256 == h || r.Replacement == h));
|
||||
var unhashed = keys.Count(k => sequence.Frames.Any(f => f.CapturedAt is { } at && f.Bytes.Length == k.Size && Ms(at) == k.Item2));
|
||||
var session = ReferenceEquals(filed, sequence);
|
||||
if (inFrames + removed + unhashed > 0 || session) hits.Add(new PhotoLookupHit(sequence.Id, inFrames, removed, unhashed, session));
|
||||
}
|
||||
results.Add(new ProbeResult(probe.Key, hits));
|
||||
}
|
||||
return Task.FromResult(new PhotoLookupResponse(results));
|
||||
}
|
||||
|
||||
static long Ms(DateTime at) => at.Ticks / TimeSpan.TicksPerMillisecond;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Like the server with <see cref="ServerCapabilities.UploadInto"/>: the photo is filed into the target even when another
|
||||
/// sequence holds it (a server-side copy, counted in <see cref="CopiedInto"/>); one the target holds answers its frame, one
|
||||
/// it tombstoned answers none. Without the capability the server ignores the flag: an upload as before.
|
||||
/// </summary>
|
||||
public async Task<CompleteUploadResponse?> UploadFileIntoAsync(string path, Guid sequenceId, string sha256, DateTime? capturedAt,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
bool capable;
|
||||
lock (_gate) capable = Capabilities.Contains(ServerCapabilities.UploadInto);
|
||||
if (!capable) return await UploadFileAsync(path, sequenceId, null, sha256, capturedAt, cancellationToken);
|
||||
var bytes = await File.ReadAllBytesAsync(path, cancellationToken);
|
||||
if (Convert.ToHexStringLower(SHA256.HashData(bytes)) != sha256)
|
||||
throw new ChronosApiException(HttpStatusCode.BadRequest, new ApiError("hash_mismatch", "hash"));
|
||||
lock (_gate)
|
||||
{
|
||||
IntoUploads++;
|
||||
var target = Find(sequenceId);
|
||||
if (target.Removed.Any(r => r.Sha256 == sha256)) return null;
|
||||
var index = target.Frames.FindIndex(f => f.Sha256 == sha256);
|
||||
if (index >= 0) return new CompleteUploadResponse(target.Frames[index].Id, target.Id, index);
|
||||
if (Sequences.Values.Where(s => !s.Unhashed && s != target).SelectMany(s => s.Frames).Any(f => f.Sha256 == sha256)) CopiedInto++;
|
||||
var frame = target.AddFrame(bytes, Path.GetFileName(path), capturedAt);
|
||||
return new CompleteUploadResponse(frame.Id, target.Id, target.Frames.IndexOf(frame));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Like the server's <c>frames/delete</c>: 404 for an unknown sequence, 403 with <see cref="ForbidFrameDeletes"/>, 409
|
||||
/// <c>frames_conflict</c> when a frame is not there or the frames version moved, 409 <c>would_empty</c>; a dry run answers
|
||||
/// the plan; else the frames go to the trash, each leaving a tombstone, and the frames version moves.
|
||||
/// </summary>
|
||||
public Task<FrameDeleteResultDto> DeleteFramesAsync(Guid sequenceId, FrameDeleteRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
var sequence = Find(sequenceId);
|
||||
if (ForbidFrameDeletes) throw new ChronosApiException(HttpStatusCode.Forbidden, new ApiError("forbidden", "delete"));
|
||||
var wanted = request.FrameIds.ToHashSet();
|
||||
var frames = sequence.Frames.Where(f => wanted.Contains(f.Id)).ToList();
|
||||
if (frames.Count != wanted.Count || (request.ExpectedFramesVersion is { } expected && expected != sequence.FramesVersion))
|
||||
throw new ChronosApiException(HttpStatusCode.Conflict, new ApiError("frames_conflict", "changed"));
|
||||
if (frames.Count == sequence.Frames.Count) throw new ChronosApiException(HttpStatusCode.Conflict, new ApiError("would_empty", "empty"));
|
||||
var bytes = frames.Sum(f => (long)f.Bytes.Length);
|
||||
if (request.DryRun)
|
||||
return Task.FromResult(new FrameDeleteResultDto(sequenceId, frames.Count, bytes, sequence.FramesVersion, sequence.Frames.Count, null, true));
|
||||
var at = DateTimeOffset.UtcNow;
|
||||
foreach (var frame in frames)
|
||||
{
|
||||
sequence.Frames.Remove(frame);
|
||||
Trashed.Add((sequenceId, frame));
|
||||
if (!sequence.Removed.Any(r => r.Sha256 == frame.Sha256)) sequence.Removed.Add(new RemovedPhotoDto(frame.Sha256, null, "deleted", at));
|
||||
}
|
||||
sequence.FramesVersion++;
|
||||
sequence.UpdatedAt = at;
|
||||
return Task.FromResult(new FrameDeleteResultDto(sequenceId, frames.Count, bytes, sequence.FramesVersion, sequence.Frames.Count,
|
||||
$"trash/photos-{Guid.NewGuid():N}", false));
|
||||
}
|
||||
}
|
||||
|
||||
public FakeSequence Add(string? title, IEnumerable<byte[]> originals, string? settingsJson = null,
|
||||
SequenceStatus status = SequenceStatus.ProxiesBuilt | SequenceStatus.ThumbsBuilt)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Nodes;
|
||||
using Chronos.Protocol;
|
||||
using Chronos.Testing;
|
||||
|
||||
namespace Chronos.Server.Tests.Api;
|
||||
|
||||
/// <summary>
|
||||
/// The wire shapes of found copies (owner review 6, #73): the photo lookup in camelCase with nulls left out, and the upload
|
||||
/// members added trailing and optional, so a client or server of before reads and writes them as it did.
|
||||
/// </summary>
|
||||
public sealed class CopyContractTests
|
||||
{
|
||||
private static readonly Guid SequenceId = Guid.Parse("01890000-0000-7000-8000-000000000002");
|
||||
private static readonly DateTime Captured = new(2026, 10, 1, 18, 0, 0, 123, DateTimeKind.Unspecified);
|
||||
|
||||
[Test]
|
||||
public void ALookupTravelsAsProbesAndHits()
|
||||
{
|
||||
var hash = new string('a', 64);
|
||||
var request = new PhotoLookupRequest(
|
||||
[
|
||||
new PhotoProbe("p1", [hash], [new PhotoKeyDto(25_000_001, Captured)], "upload-1"),
|
||||
new PhotoProbe("p2", [hash]),
|
||||
]);
|
||||
var json = JsonNode.Parse(JsonSerializer.Serialize(request, ProtocolJson.Default.PhotoLookupRequest))!.AsObject();
|
||||
Assert.SequenceEqual(["probes"], json.Select(p => p.Key));
|
||||
Assert.SequenceEqual(["key", "sha256", "unhashed", "sessionKey"], json["probes"]![0]!.AsObject().Select(p => p.Key));
|
||||
Assert.SequenceEqual(["key", "sha256"], json["probes"]![1]!.AsObject().Select(p => p.Key));
|
||||
Assert.SequenceEqual(["size", "capturedAt"], json["probes"]![0]!["unhashed"]![0]!.AsObject().Select(p => p.Key));
|
||||
var back = JsonSerializer.Deserialize(json.ToJsonString(), ProtocolJson.Default.PhotoLookupRequest)!;
|
||||
Assert.Equal(2, back.Probes.Count);
|
||||
Assert.Equal(("p1", "upload-1", Captured), (back.Probes[0].Key, back.Probes[0].SessionKey, back.Probes[0].Unhashed![0].CapturedAt));
|
||||
Assert.Null(back.Probes[1].Unhashed);
|
||||
// The limit counts hashes, unhashed keys and session keys; the count is never sent.
|
||||
Assert.Equal(4, request.CountItems());
|
||||
Assert.Equal((200, 20_000), (PhotoLookupRequest.MaxProbes, PhotoLookupRequest.MaxItems));
|
||||
|
||||
var response = new PhotoLookupResponse([new ProbeResult("p1", [new PhotoLookupHit(SequenceId, 1, 0, 1, true)]), new ProbeResult("p2", [])]);
|
||||
var answer = JsonNode.Parse(JsonSerializer.Serialize(response, ProtocolJson.Default.PhotoLookupResponse))!.AsObject();
|
||||
Assert.SequenceEqual(["sequenceId", "hashes", "removed", "unhashed", "sessionKey"], answer["results"]![0]!["hits"]![0]!.AsObject().Select(p => p.Key));
|
||||
var read = JsonSerializer.Deserialize(answer.ToJsonString(), ProtocolJson.Default.PhotoLookupResponse)!;
|
||||
Assert.Equal(response.Results[0].Hits[0], read.Results[0].Hits[0]);
|
||||
Assert.Empty(read.Results[1].Hits);
|
||||
Assert.Equal(("photo-lookup", "upload-into"), (ServerCapabilities.PhotoLookup, ServerCapabilities.UploadInto));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AnUploadIntoATargetIsAnOptionalTrailingFlag()
|
||||
{
|
||||
// A client of before sends no flag: an upload as before.
|
||||
var old = JsonSerializer.Deserialize(
|
||||
"""{ "sequenceId": null, "fileName": "IMG_0001.JPG", "size": 10, "sha256": "ab", "capturedAt": null, "sessionKey": "upload-1" }""",
|
||||
ProtocolJson.Default.StartUploadRequest)!;
|
||||
Assert.Equal((false, false), (old.Restore, old.IntoTarget));
|
||||
var into = new StartUploadRequest(SequenceId, "IMG_0001.JPG", 10, "ab", null, null, IntoTarget: true);
|
||||
var json = JsonNode.Parse(JsonSerializer.Serialize(into, ProtocolJson.Default.StartUploadRequest))!.AsObject();
|
||||
Assert.Equal("intoTarget", json.Last().Key);
|
||||
Assert.True(json["intoTarget"]!.GetValue<bool>());
|
||||
Assert.True(JsonSerializer.Deserialize(json.ToJsonString(), ProtocolJson.Default.StartUploadRequest)!.IntoTarget);
|
||||
|
||||
// A server of before answers without Copied.
|
||||
var answer = JsonSerializer.Deserialize("""{ "uploadId": null, "chunkSize": 0, "received": [], "alreadyExists": true, "frameId": null }""",
|
||||
ProtocolJson.Default.StartUploadResponse)!;
|
||||
Assert.False(answer.Copied);
|
||||
var copied = new StartUploadResponse(null, 0, [], true, SequenceId, Copied: true);
|
||||
var copiedJson = JsonNode.Parse(JsonSerializer.Serialize(copied, ProtocolJson.Default.StartUploadResponse))!.AsObject();
|
||||
Assert.Equal("copied", copiedJson.Last().Key);
|
||||
var back = JsonSerializer.Deserialize(copiedJson.ToJsonString(), ProtocolJson.Default.StartUploadResponse)!;
|
||||
Assert.Equal(((Guid?)SequenceId, true, true), (back.FrameId, back.AlreadyExists, back.Copied));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user