fix(copies): close the owner review 6 second verification findings

Upload again now deletes the gone pair row once the new sequence is linked, so
the pair stops reading "deleted on server" or "kept here". A linked upload the
server refuses into its sequence (403 for an account without Edit that does not
own it) falls back to ordinary uploads instead of failing; an Integrate that
would add photos to such a sequence is blocked in its plan (NoAddRight).
Automatic photo transfers pause on a metered connection whatever the option
says. Integrate trashes server photos only against the manifest version that
checked the winner, and a merge is blocked while the other sequence holds a
damaged photo nothing else holds (DamagedPhotos), so nothing unverified reaches
the trash.

The plan and the confirmations now say what really happens: replaced versions
are no longer counted as kept, a merge lists the kept sequence's replaced
photos, plan lines use the text colour, an integrated pair that left photos out
says new photos move by hand, and a merging pair reads "merging" with its
progress. The Compare dialog gets per-side tooltips, class sizes for both
sides, policy-aware class tooltips, column headings and readable file names;
the sync table shows "deleted there" with Review and warns on skipped rows; the
Edit picker names the server, the Library card shows the match status second,
a deleted server sequence is named instead of "0 photos", and the match
tooltips stop calling a sequence a copy. The capture scenes use the server
name, the link names and consistent sample sizes.

Refs #73

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-17 16:08:49 +01:00
1 parent b34b6b6fe0
commit 9657c1711d
44 files changed
+802 -128

No files matched your search

+22
View File
@@ -49,6 +49,28 @@ commits follow Conventional Commits (release notes are generated from them by `C
versions under the side that loses them; plan lines read as queued; the Italian version choice fits.
- Matches: counts first in the This side and Other side cells, the integrating progress as a share ("x of y" in the
tooltip), counts grouped by thousands, and a match between this PC's archives names the other archive.
- Upload again after the server deleted its sequence removes the old "deleted on server" or "kept here" pair once
the new sequence is linked.
- A linked upload the server refuses into its sequence (an account without the Edit right that does not own it) goes
on as new photos, which the server files by their hash; an Integrate that would add photos to such a sequence is
blocked in its plan instead.
- Automatic photo transfers pause on a metered connection even when the metered option is off; manual transfers
follow the option as before.
- Integrate trashes a server photo only while the server sequence is still the version the winner check read.
- A merge whose other sequence holds a photo Verify found changed or damaged, which nothing else holds, is blocked
in its plan.
- The Plan counts as second versions only those kept beside their pair, a merge plan and its confirmation list the
kept sequence's photos a winning version replaces, and plan lines are drawn in the text colour.
- An integrated pair whose Integrate left photos out says new photos move on Upload and Download; a merging pair reads
"merging" and follows the merge's progress.
- Compare dialog: All server / All other say what they take; the class table shows the size of photos held only on
the other side (both sides in the tooltip), has column headings and tooltips that follow the chosen policy and the
merge; Choose each keeps file names readable; the Details part has column headings that follow the kept sequence.
- Sync table: skipped rows carry the warning glyph and Upload all says how many are left out; a linked or integrated
pair whose match deleted photos reads "deleted there · n" with Review.
- The Edit picker's twin tooltip names the server, not its key; the Library card shows the match status second; a
match whose server sequence was deleted names the server instead of "0 photos"; the match tooltips no longer call a
sequence a "copy".
## [1.1.1] — 2026-11-16
+4
View File
@@ -915,3 +915,7 @@ One line per decision: date · decision · alternative · reason.
| 2026-11-17 | A merge's second versions are found again from the kept sequence's frames (`CopySides.VersionsAsync`: two usable hashed frames of one sub-second capture instant with different SHA-256), with no new table (#73) | A table of the filed pairs | The frames already carry what the pair needs; the Library/Edit list with Drop… is a follow-up |
| 2026-11-17 | Compare › Details groups the lines of one setting into one row (`SyncText.DetailSetting`) with one choice applied to every path; values unknown to the sync's wording read "changed", the raw JSON in the tooltip (#73) | One row per JSON path | An Auto parameter's members and the parked positions are one decision for the user |
| 2026-11-17 | The Compare photo list keeps each row's selection from the list's SelectionChanged (`ListSelection.SyncsRows`), not only from the realised rows' IsSelected binding (#73) | Turn virtualisation off | A long class list must stay virtualised; Ctrl+A must reach the hidden rows |
| 2026-11-17 | Automatic photo transfers (an integrated pair's new photos) are held on a metered connection whatever the "pause on metered" option says; manual transfers follow the option (#73) | Follow the option for every transfer | Owner Q6: new photos move by themselves "with a metered pause"; the option still governs what the user starts |
| 2026-11-17 | A linked upload whose IntoTarget the server refuses (403 forbidden) falls back for the rest of the job to ordinary uploads the server files by SHA-256; an Integrate that would send photos into a server sequence the account neither owns nor may edit is blocked in its plan (`CopyBlock.NoAddRight`) (#73) | Fail the upload; ask the server for a new right | A Read+Upload account keeps uploading as before 1.2; an Integrate cannot fall back without leaving its plan, so it stops before anything moves |
| 2026-11-17 | A merge is blocked (`CopyBlock.DamagedPhotos`) when the other sequence holds a Corrupt-flagged photo whose current file content nothing in the kept sequence or elsewhere in this PC's index holds; one held elsewhere goes to the trash as before (#73) | List the damaged photos in the plan and trash them | The simplest safe option: nothing unverified goes to the trash, and Verify/repair already exist |
| 2026-11-17 | The Plan's "Server uses ours" line still counts every version sent, replaced or kept beside (#73) | Count it as the Versions line does | The line says which side's file the server ends up with, true in both cases |
+1
View File
@@ -265,6 +265,7 @@
<data name="Archive.Log.SyncChanged" xml:space="preserve"><value>{0}: changed since it was archived, not uploaded</value><comment>long: job log line of an upload; {0} file name</comment></data>
<data name="Archive.Log.SyncDeletedHere" xml:space="preserve"><value>{0}: deleted on this PC, not downloaded</value><comment>long: job log line of a download; {0} file name</comment></data>
<data name="Archive.Log.SyncDeletedThere" xml:space="preserve"><value>{0}: deleted on the server, not uploaded</value><comment>long: job log line of an upload; {0} file name</comment></data>
<data name="Archive.Log.SyncIntoRefused" xml:space="preserve"><value>The server refused photos into its sequence; they go as new photos and the server files them by their hash</value><comment>long: job log line of an upload</comment></data>
<data name="Archive.Log.SyncFrameChanged" xml:space="preserve"><value>{0}: its frame here changed meanwhile, not downloaded</value><comment>long: job log line of a download; {0} file name of the server's copy of a photo this PC holds in another encoding</comment></data>
<data name="Archive.Log.SyncMissing" xml:space="preserve"><value>{0}: missing, not uploaded</value><comment>long: job log line of an upload; {0} file name</comment></data>
<data name="Archive.Log.SyncNoPreview.one" xml:space="preserve"><value>{0:N0} frame has neither proxy nor thumbnail on the server</value><comment>long: job log line of a proxy download</comment></data>
+2
View File
@@ -138,6 +138,7 @@
<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.DamagedPhotos" xml:space="preserve"><value>Verify found changed or damaged photos in {0} that nothing else holds; repair them before merging.</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>
@@ -150,6 +151,7 @@
<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.NoAddRight" xml:space="preserve"><value>This account may not add photos to a server sequence it does not own; ask for the Edit right.</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>
+3
View File
@@ -312,6 +312,7 @@
<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} %</value></data>
<data name="Server.Copies.State.Merging" xml:space="preserve"><value>merging · {0} %</value></data>
<data name="Server.Copies.State.Progress" xml:space="preserve"><value>{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>
@@ -457,5 +458,7 @@
<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:N0} photo exists only in {1}</value><comment>long</comment></data>
<data name="Server.Copies.Confirm.Merge.OnlyHere.other" xml:space="preserve"><value>{0:N0} photos exist only in {1}</value><comment>long</comment></data>
<data name="Server.Copies.Confirm.Merge.Replaced.one" xml:space="preserve"><value>{0:N0} photo of {1} goes to the trash, replaced</value><comment>long</comment></data>
<data name="Server.Copies.Confirm.Merge.Replaced.other" xml:space="preserve"><value>{0:N0} photos of {1} go to the trash, replaced</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>
+26 -10
View File
@@ -1153,10 +1153,10 @@
<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.DeletedOnServer" xml:space="preserve"><value>the server deleted its sequence</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.Sync.UploadAllSkipping.one" xml:space="preserve"><value>Upload the sequences only here; {0} is left out (its row says why).</value></data>
<data name="Tooltips.Server.Sync.UploadAllSkipping.other" xml:space="preserve"><value>Upload the sequences only here; {0} are left out (each row says why).</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>
@@ -1181,17 +1181,30 @@
<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.Merging" xml:space="preserve"><value>Being merged; the job shows each step.</value></data>
<data name="Tooltips.Server.Copies.Plan.DeletedInOther" xml:space="preserve"><value>Photos the other sequence deleted that the kept one holds: they stay in the kept one.</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.IntegratedByHand" xml:space="preserve"><value>Some photos were left out: new photos move on Upload and Download.</value></data>
<data name="Tooltips.Server.Copies.State.RemoteGone" xml:space="preserve"><value>The server deleted its sequence; 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 own.</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.SameUnhashed.Integrate" xml:space="preserve"><value>Same size and capture time; one side is not verified yet. Integrate counts them as one photo and moves neither.</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.OnlyHere.Choose" xml:space="preserve"><value>Photos only this side holds; Integrate copies those you tick to the other.</value></data>
<data name="Tooltips.Server.Copies.Class.OnlyHere.Merge" xml:space="preserve"><value>Photos only the kept sequence holds; they stay in it.</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.OnlyThere.Choose" xml:space="preserve"><value>Photos only the other side holds; Integrate copies those you tick here.</value></data>
<data name="Tooltips.Server.Copies.Class.OnlyThere.Merge" xml:space="preserve"><value>Photos only the other sequence holds; Merge copies each into the kept one.</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.Differs.ThisPcWins" xml:space="preserve"><value>Same name and capture time, different files. This PC's file replaces the server's, which goes to the trash.</value></data>
<data name="Tooltips.Server.Copies.Class.Differs.OtherWins" xml:space="preserve"><value>Same name and capture time, different files. The server's file replaces this PC's, which goes to the trash.</value></data>
<data name="Tooltips.Server.Copies.Class.Differs.KeptWins" xml:space="preserve"><value>Same name and capture time, different files. The kept sequence's file stays; the other's goes to the trash with it.</value></data>
<data name="Tooltips.Server.Copies.Class.Differs.OtherCopyWins" xml:space="preserve"><value>Same name and capture time, different files. The other sequence's file replaces the kept one's, which goes to the trash.</value></data>
<data name="Tooltips.Server.Copies.Class.Differs.Choose" xml:space="preserve"><value>Same name and capture time, different files. Choose for each photo; Leave changes nothing.</value></data>
<data name="Tooltips.Server.Copies.Class.Differs.Merge" xml:space="preserve"><value>Same name and capture time, different files. The kept sequence 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>
@@ -1209,9 +1222,12 @@
<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.Detail.AllHere" xml:space="preserve"><value>Take this PC's value for every difference.</value></data>
<data name="Tooltips.Server.Copies.Detail.AllThere" xml:space="preserve"><value>Take the value of {0} for every difference.</value></data>
<data name="Tooltips.Server.Copies.Detail.AllKept" xml:space="preserve"><value>Take the kept sequence's value for every difference.</value></data>
<data name="Tooltips.Server.Copies.Detail.AllOther" xml:space="preserve"><value>Take the other sequence'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.Leave" xml:space="preserve"><value>Other projects stay where they are; Edit marks the two workspace projects 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>
@@ -1233,10 +1249,10 @@
<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.Status.RemoteGone" xml:space="preserve"><value>{0} deleted its copy of this sequence; this PC's sequence stays until you choose.</value></data>
<data name="Tooltips.Library.Status.RemoteGone" xml:space="preserve"><value>{0} deleted its sequence; this PC's sequence stays 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" xml:space="preserve"><value>What Chronos does with the matches it finds (the same sequence twice). 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>
@@ -1247,5 +1263,5 @@
<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>
<data name="Tooltips.Settings.CopyProjects.Leave" xml:space="preserve"><value>Other projects stay where they are; Edit marks the two workspace projects as twins.</value></data>
</root>
+1
View File
@@ -259,6 +259,7 @@
<data name="Archive.Log.SyncChanged" xml:space="preserve"><value>{0}: cambiato da quando è stato archiviato, non caricato</value></data>
<data name="Archive.Log.SyncDeletedHere" xml:space="preserve"><value>{0}: eliminato su questo PC, non scaricato</value></data>
<data name="Archive.Log.SyncDeletedThere" xml:space="preserve"><value>{0}: eliminato sul server, non caricato</value></data>
<data name="Archive.Log.SyncIntoRefused" xml:space="preserve"><value>Il server ha rifiutato foto nella sua sequenza; vanno come foto nuove e il server le archivia per hash</value><comment>long: job log line of an upload</comment></data>
<data name="Archive.Log.SyncFrameChanged" xml:space="preserve"><value>{0}: il suo fotogramma qui è cambiato nel frattempo, non scaricato</value></data>
<data name="Archive.Log.SyncMissing" xml:space="preserve"><value>{0}: mancante, non caricato</value></data>
<data name="Archive.Log.SyncNoPreview.one" xml:space="preserve"><value>{0:N0} fotogramma non ha né proxy né miniatura sul server</value></data>
+2
View File
@@ -138,6 +138,7 @@
<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.DamagedPhotos" xml:space="preserve"><value>Verifica ha trovato foto cambiate o danneggiate in {0} che nient'altro conserva; riparale prima di unire.</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>
@@ -150,6 +151,7 @@
<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.NoAddRight" xml:space="preserve"><value>Questo account non può aggiungere foto a una sequenza del server non sua; chiedi il permesso Modifica.</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>
+3
View File
@@ -309,6 +309,7 @@
<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} %</value></data>
<data name="Server.Copies.State.Merging" xml:space="preserve"><value>in unione · {0} %</value></data>
<data name="Server.Copies.State.Progress" xml:space="preserve"><value>{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>
@@ -454,5 +455,7 @@
<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:N0} foto esiste solo in {1}</value><comment>long</comment></data>
<data name="Server.Copies.Confirm.Merge.OnlyHere.other" xml:space="preserve"><value>{0:N0} foto esistono solo in {1}</value><comment>long</comment></data>
<data name="Server.Copies.Confirm.Merge.Replaced.one" xml:space="preserve"><value>{0:N0} foto di {1} va nel cestino, sostituita</value><comment>long</comment></data>
<data name="Server.Copies.Confirm.Merge.Replaced.other" xml:space="preserve"><value>{0:N0} foto di {1} vanno nel cestino, sostituite</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>
+26 -10
View File
@@ -1151,10 +1151,10 @@
<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.DeletedOnServer" xml:space="preserve"><value>il server ha eliminato la sua sequenza</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.Sync.UploadAllSkipping.one" xml:space="preserve"><value>Carica le sequenze presenti solo qui; {0} viene saltata (la sua riga dice perché).</value></data>
<data name="Tooltips.Server.Sync.UploadAllSkipping.other" xml:space="preserve"><value>Carica le sequenze presenti solo qui; {0} vengono saltate (ogni riga dice perché).</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>
@@ -1179,17 +1179,30 @@
<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.Merging" xml:space="preserve"><value>In unione; il lavoro mostra ogni passo.</value></data>
<data name="Tooltips.Server.Copies.Plan.DeletedInOther" xml:space="preserve"><value>Foto eliminate nell'altra sequenza che quella tenuta conserva: restano in quella tenuta.</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.IntegratedByHand" xml:space="preserve"><value>Alcune foto sono state escluse: le foto nuove si spostano con Carica e Scarica.</value></data>
<data name="Tooltips.Server.Copies.State.RemoteGone" xml:space="preserve"><value>Il server ha eliminato la sua sequenza; quella 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.</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.SameUnhashed.Integrate" xml:space="preserve"><value>Stessa dimensione e ora di scatto; un lato non è ancora verificato. Integra le conta come una foto e non sposta nessuna delle due.</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.OnlyHere.Choose" xml:space="preserve"><value>Foto che ha solo questo lato; Integra copia sull'altro quelle che spunti.</value></data>
<data name="Tooltips.Server.Copies.Class.OnlyHere.Merge" xml:space="preserve"><value>Foto che ha solo la sequenza tenuta; restano lì.</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.OnlyThere.Choose" xml:space="preserve"><value>Foto che ha solo l'altro lato; Integra copia qui quelle che spunti.</value></data>
<data name="Tooltips.Server.Copies.Class.OnlyThere.Merge" xml:space="preserve"><value>Foto che ha solo l'altra sequenza; Unisci le copia tutte in quella tenuta.</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.Differs.ThisPcWins" xml:space="preserve"><value>Stesso nome e ora di scatto, file diversi. Il file di questo PC sostituisce quello del server, che va nel cestino.</value></data>
<data name="Tooltips.Server.Copies.Class.Differs.OtherWins" xml:space="preserve"><value>Stesso nome e ora di scatto, file diversi. Il file del server sostituisce quello di questo PC, che va nel cestino.</value></data>
<data name="Tooltips.Server.Copies.Class.Differs.KeptWins" xml:space="preserve"><value>Stesso nome e ora di scatto, file diversi. Il file della sequenza tenuta resta; quello dell'altra va nel cestino con lei.</value></data>
<data name="Tooltips.Server.Copies.Class.Differs.OtherCopyWins" xml:space="preserve"><value>Stesso nome e ora di scatto, file diversi. Il file dell'altra sequenza sostituisce quello della tenuta, che va nel cestino.</value></data>
<data name="Tooltips.Server.Copies.Class.Differs.Choose" xml:space="preserve"><value>Stesso nome e ora di scatto, file diversi. Scegli per ogni foto; Lascia non cambia nulla.</value></data>
<data name="Tooltips.Server.Copies.Class.Differs.Merge" xml:space="preserve"><value>Stesso nome e ora di scatto, file diversi. La sequenza tenuta conserva 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>
@@ -1207,9 +1220,12 @@
<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.Detail.AllHere" xml:space="preserve"><value>Prende il valore di questo PC per ogni differenza.</value></data>
<data name="Tooltips.Server.Copies.Detail.AllThere" xml:space="preserve"><value>Prende il valore di {0} per ogni differenza.</value></data>
<data name="Tooltips.Server.Copies.Detail.AllKept" xml:space="preserve"><value>Prende il valore della sequenza tenuta per ogni differenza.</value></data>
<data name="Tooltips.Server.Copies.Detail.AllOther" xml:space="preserve"><value>Prende il valore dell'altra sequenza 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.Leave" xml:space="preserve"><value>Gli altri progetti restano dove sono; Modifica segna i due progetti di lavoro come gemelli.</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>
@@ -1231,10 +1247,10 @@
<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.Status.RemoteGone" xml:space="preserve"><value>{0} ha eliminato la sua copia di questa sequenza; quella di questo PC resta finché non scegli.</value></data>
<data name="Tooltips.Library.Status.RemoteGone" xml:space="preserve"><value>{0} ha eliminato la sua sequenza; quella di questo PC resta 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" xml:space="preserve"><value>Cosa fa Chronos con le corrispondenze che trova (la stessa sequenza due volte). 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>
@@ -1245,5 +1261,5 @@
<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>
<data name="Tooltips.Settings.CopyProjects.Leave" xml:space="preserve"><value>Gli altri progetti restano dove sono; Modifica segna i due progetti di lavoro come gemelli.</value></data>
</root>
+13 -4
View File
@@ -100,7 +100,11 @@ internal sealed class SampleCopyEngine : ICopyEngine
return Task.FromResult(new MergePlan(copyId, keep ?? Guid.Empty, keepsHere ? pair.Copy.OtherId ?? Guid.Empty : pair.Copy.LocalId, choices, steps, [],
[new RenderStep(Guid.CreateVersion7(), "Alps 2025 4K.mp4", 640_000_000, null)], null, choices.Details.Count, projects,
["card:CANON-EOS-R5:2025-07-14"], [], [pair.Copy.Server ?? "nas"], new DeletePlan([], []), drop.Bytes / 20, 1_240_000_000_000, blocks,
1, 1, 1, 1, "sample"));
1, 1, 1, 1, "sample")
{
// The link that moves is shown by the server's name, as SequenceMerger names it.
LinkNames = [drop.Servers.FirstOrDefault() ?? pair.Copy.Server ?? "nas"],
});
}
public async Task<Job> EnqueueMergeAsync(JobEngine engine, MergePlan plan, CancellationToken ct)
@@ -152,7 +156,8 @@ internal sealed class SampleCopyEngine : ICopyEngine
public Task<IReadOnlyList<CopyTwin>> TwinsAsync(CancellationToken ct) => Task.FromResult<IReadOnlyList<CopyTwin>>(
[.. _pairs.Where(p => p.Copy is { Kind: CopyKind.LocalServer, State: CopyState.Integrated or CopyState.Linked })
.Select(p => new CopyTwin(p.Copy.Id, p.Copy.LocalId, p.Here.Where, "Main", p.Copy.Server ?? string.Empty, p.Copy.RemoteId ?? Guid.Empty, "Vertical"))]);
.Select(p => new CopyTwin(p.Copy.Id, p.Copy.LocalId, p.Here.Where, "Main", p.Copy.Server ?? string.Empty, p.Copy.RemoteId ?? Guid.Empty, "Vertical",
p.There.Where))]);
/// <summary>
/// The photo steps of the choices: photos only on one side travel to the other (unless Choose each leaves them out);
@@ -236,7 +241,7 @@ internal static class SampleCopies
{
var at = start.AddSeconds((from + i) * 10);
var name = $"{prefix}{from + i + 1:0000}.CR3";
var size = 24_000_000L + (from + i) % 7 * 310_000;
var size = Size(from + i);
var sha = $"{cls}{from + i:x8}".PadRight(64, '0');
var h = here ? new CopyPhotoInput(Guid.CreateVersion7(), from + i, name, sha, size, at, false) : null;
var t = there ? new CopyPhotoInput(Guid.CreateVersion7(), from + i, name, cls == PhotoClass.Differs ? sha.Replace('0', '1') : sha, size + (cls == PhotoClass.Differs ? 4_096 : 0), at, false) : null;
@@ -256,8 +261,12 @@ internal static class SampleCopies
Math.Min(1000, shared * 1000 / smaller), shared * 1000 / Math.Max(1, local + other - shared), hints);
}
/// <summary>The size of the sample photo at <paramref name="index"/> (24.0 to 25.9 MB).</summary>
private static long Size(int index) => 24_000_000L + index % 7 * 310_000;
/// <summary>A side's facts; its bytes are the sum of its photos' sizes, so the class table adds up to the header.</summary>
internal static CopyFacts Facts(Sequence sequence, string where, int photos, bool originals = false, IReadOnlyList<string>? servers = null) =>
new(sequence.DisplayTitle, where, sequence.ArchiveId, photos, photos * 24_000_000L, sequence.FirstCapture, sequence.LastCapture,
new(sequence.DisplayTitle, where, sequence.ArchiveId, photos, Enumerable.Range(0, photos).Sum(i => Size(i)), sequence.FirstCapture, sequence.LastCapture,
sequence.CameraModel, photos, sequence.Origin, servers ?? [], originals);
internal static ProjectLine Project(string name, bool main, int versions, int daysAgo) =>
+2
View File
@@ -341,6 +341,8 @@ public sealed class SampleData
FoundAt = Now.AddDays(-2),
UpdatedAt = Now.AddHours(-3),
AnsweredAt = state == CopyState.KeptApart ? Now.AddDays(-12) : null,
// The sample's integrated pair left nothing out: new photos move by themselves.
AutoPhotos = state == CopyState.Integrated,
};
CopyProjectsView Projects(bool other) => new(
[SampleCopies.Project("Main", true, 4, 2), SampleCopies.Project("Vertical", false, 3, 5)],
@@ -254,7 +254,8 @@ public sealed class AppServices : IAsyncDisposable
/// <summary>
/// What the planners know of this PC and the signed-in account. The account's rights stand for its rights over the
/// server's sequence: the server enforces ownership itself, so OwnsOrAdmin reads Delete or an admin right.
/// server's sequence: the server enforces ownership itself, so OwnsOrAdmin reads Delete or an admin right; the account's
/// id lets the Integrate planner see the sequences it owns (sending into one it neither owns nor may edit is refused).
/// </summary>
private CopyPlanContext CopyContext(ISyncRemote? remote)
{
@@ -266,7 +267,10 @@ public sealed class AppServices : IAsyncDisposable
return new CopyPlanContext(System.Environment.MachineName, remote is null ? null : Server.ServerName, rights.CanUpload, rights.CanFetchOriginals,
rights.CanEdit, Has(Permissions.Delete), Has(Permissions.Delete) || Has(Permissions.ManageArchive) || Has(Permissions.ManageUsers),
remote is not null && Sync.HasProjects, user is { QuotaBytes: > 0 } ? Math.Max(0, user.QuotaBytes - user.UsedBytes) : null, new HashSet<Guid>(),
originals);
originals)
{
UserId = user?.Id,
};
}
/// <summary>The name a server key is shown by: the known server's name (by its id), else none (the key is shown).</summary>
+9 -2
View File
@@ -100,8 +100,15 @@ public sealed class SequenceItem : ObservableObject
public string TagsText => string.Join(", ", _sequence.Tags);
/// <summary>Status glyphs of the card and the list (DESIGN §4: glyph + word, never colour alone).</summary>
public IReadOnlyList<CardStatus> Statuses => _match is { } match ? [.. BuildStatuses(_sequence, _isAnalysing), match] : BuildStatuses(_sequence, _isAnalysing);
/// <summary>
/// Status glyphs of the card and the list (DESIGN §4: glyph + word, never colour alone). The match status, the one that
/// asks for a choice, follows the analysis status, so a narrow card cuts the others first.
/// </summary>
public IReadOnlyList<CardStatus> Statuses => WithMatch(BuildStatuses(_sequence, _isAnalysing), _match);
/// <summary><paramref name="statuses"/> with <paramref name="match"/> second (right after the analysis status).</summary>
internal static IReadOnlyList<CardStatus> WithMatch(IReadOnlyList<CardStatus> statuses, CardStatus? match) => match is null ? statuses
: statuses.Count == 0 ? [match] : [statuses[0], match, .. statuses.Skip(1)];
/// <summary>
/// "Also elsewhere" or "Deleted there" (owner review 6, #73): the sequence is in a pair that asks for a choice; set by the
@@ -343,7 +343,7 @@ public sealed class SequencePickerViewModel : LocalizedViewModel
: twins.FirstOrDefault(t => t.LocalId == item.SequenceId && t.ServerProject is not null);
if (twin is null) continue;
var server = string.Equals(twin.Server, Shell.Services.Sync.Server, StringComparison.OrdinalIgnoreCase)
? Shell.Services.Server.Flow.Info?.Name ?? twin.Server : twin.Server;
? Shell.Services.Server.Flow.Info?.Name ?? twin.ServerName : twin.ServerName;
if (item.Entry.IsServerHome) item.SetTwin(twin.LocalHome, twin.LocalProject);
else item.SetTwin(server, twin.ServerProject);
}
@@ -158,6 +158,7 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
if (value is null || !Set(ref _policy, value)) return;
OnPropertyChanged(nameof(PolicyToolTip));
OnPropertyChanged(nameof(IsChoosing));
foreach (var row in _classes) row.Policy = value.Value;
BuildPhotos();
Changed();
}
@@ -209,6 +210,18 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
public string AllHereText => Loc.L(IsMerge ? "Server.Copies.Detail.AllKept" : "Server.Copies.Detail.AllThisPc");
public string AllThereText => Loc.L(IsMerge ? "Server.Copies.Detail.AllOther" : "Server.Copies.Detail.AllServer");
/// <summary>"Take this PC's value for every difference." (a merge: the kept sequence's).</summary>
public string AllHereToolTip => Loc.L(IsMerge ? "Tooltips.Server.Copies.Detail.AllKept" : "Tooltips.Server.Copies.Detail.AllHere");
/// <summary>"Take the server's value for every difference." (a merge: the other sequence's).</summary>
public string AllThereToolTip => Loc.L(IsMerge ? "Tooltips.Server.Copies.Detail.AllOther" : "Tooltips.Server.Copies.Detail.AllThere", ServerName);
/// <summary>The Details part's first value column: this PC, or the kept sequence ("Into Old archive"); the pair's first before one is kept.</summary>
public string DetailHereHeading => IsMerge && _keepId is null ? Here.Where : HereHeading;
/// <summary>The Details part's second value column: the server, or the other sequence.</summary>
public string DetailThereHeading => ThereHeading;
/// <summary>A merge keeping the pair's other sequence: the review compares the pair's first with it, so its two columns swap.</summary>
private bool Swapped => IsMerge && _keepId is { } keep && keep == Copy.OtherId;
@@ -340,7 +353,7 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
private void Build(CopyReview review)
{
Classes = [.. review.Photos.Totals.Where(t => t.Count > 0).Select(t => new CopyClassRow(t))];
Classes = [.. review.Photos.Totals.Where(t => t.Count > 0).Select(t => new CopyClassRow(t, _policy.Value, IsMerge) { Swapped = Swapped })];
_class = _classes.FirstOrDefault(c => c.Class == _startClass)
?? _classes.FirstOrDefault(c => c.Class is not (PhotoClass.Same or PhotoClass.Converted))
?? _classes.FirstOrDefault();
@@ -430,10 +443,18 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
var wasSwapped = Swapped;
_keepId = option.SequenceId;
foreach (var other in _keep.Where(o => !ReferenceEquals(o, option))) other.SetQuietly(false);
foreach (var row in _classes) row.Swapped = Swapped;
Reorient(wasSwapped);
RaiseHeadings();
Changed();
}
private void RaiseHeadings()
{
OnPropertyChanged(nameof(HereHeading));
OnPropertyChanged(nameof(ThereHeading));
Changed();
OnPropertyChanged(nameof(DetailHereHeading));
OnPropertyChanged(nameof(DetailThereHeading));
}
/// <summary>A choice changed: the plan follows once the user pauses.</summary>
@@ -503,6 +524,7 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
var wasSwapped = Swapped;
_keepId = merge.KeepId;
foreach (var option in _keep) option.SetQuietly(option.SequenceId == _keepId);
foreach (var row in _classes) row.Swapped = Swapped;
Reorient(wasSwapped);
}
}
@@ -555,11 +577,12 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
var blocks = new List<CopyBlockLine>();
if (_plan is { } plan)
{
// Warnings lead each column: last copies, then the trash.
Lasts(plan.LastCopies, here, there);
Photos(plan.Photos, PhotoAction.Fetch, PhotoAction.FetchVersion, "Server.Copies.Plan.Receives", here);
Photos(plan.Photos, PhotoAction.Send, PhotoAction.SendVersion, "Server.Copies.Plan.Receives", there);
Trash(plan.Photos, PhotoAction.TrashHere, here);
Trash(plan.Photos, PhotoAction.TrashThere, there);
Photos(plan.Photos, PhotoAction.Fetch, PhotoAction.FetchVersion, PhotoAction.TrashHere, "Server.Copies.Plan.Receives", here);
Photos(plan.Photos, PhotoAction.Send, PhotoAction.SendVersion, PhotoAction.TrashThere, "Server.Copies.Plan.Receives", there);
var versions = plan.Photos.Count(p => p.Action == PhotoAction.SendVersion);
if (versions > 0) there.Add(new(Loc.Plural("Server.Copies.Plan.ServerUsesOurs", versions, ServerName), Loc.L("Tooltips.Server.Copies.Plan.ServerUsesOurs")));
// A detail changes on the side that does not keep its own value: this PC takes the server's, the server this PC's.
@@ -580,7 +603,9 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
else if (_merge is { } merge)
{
Lasts(merge.LastCopies, here, there);
Photos(merge.Photos, PhotoAction.Fetch, PhotoAction.FetchVersion, "Server.Copies.Plan.Receives", here);
// The kept sequence's versions the other's replace go to its archive's trash (Other one wins, or chosen so).
Trash(merge.Photos, PhotoAction.TrashHere, here);
Photos(merge.Photos, PhotoAction.Fetch, PhotoAction.FetchVersion, PhotoAction.TrashHere, "Server.Copies.Plan.Receives", here);
if (merge.DetailChanges > 0) here.Add(new(Loc.Plural("Server.Copies.Plan.Details", merge.DetailChanges)));
if (merge.Renders.Count > 0) here.Add(new(Loc.Plural("Server.Copies.Plan.Renders", merge.Renders.Count)));
if (merge.Projects.Count > 0) here.Add(new(Loc.Plural("Server.Copies.Plan.Projects", merge.Projects.Count)));
@@ -601,8 +626,7 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
HereLines = here;
ThereLines = there;
Blocks = blocks;
OnPropertyChanged(nameof(HereHeading));
OnPropertyChanged(nameof(ThereHeading));
RaiseHeadings();
OnPropertyChanged(nameof(ApplyToolTip));
_apply.RaiseCanExecuteChanged();
@@ -614,11 +638,12 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
if (theirs > 0) t.Add(new(Loc.Plural("Server.Copies.Plan.LastCopies", theirs), Loc.L("Tooltips.Server.Copies.Plan.LastCopies"), true));
}
static void Photos(IReadOnlyList<PhotoStep> steps, PhotoAction a, PhotoAction b, string key, List<CopyPlanLine> lines)
// A version step whose photo has a trash step on the same side replaces it: received, not kept as a second version.
static void Photos(IReadOnlyList<PhotoStep> steps, PhotoAction a, PhotoAction b, PhotoAction trash, string key, List<CopyPlanLine> lines)
{
var moving = steps.Where(s => s.Action == a || s.Action == b).ToList();
if (moving.Count > 0) lines.Add(new(Loc.Plural(key, moving.Count, Formatting.Bytes(moving.Sum(s => s.Bytes)))));
var kept = steps.Count(s => s.Action == b);
var kept = KeptVersions(steps, b, trash);
if (kept > 0) lines.Add(new(Loc.Plural("Server.Copies.Plan.Versions", kept)));
}
@@ -665,7 +690,7 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
{
if (_plan is { CanApply: true } plan)
{
if (plan.Destructive && !_shell.Services.Dialogs.Confirm(ReplaceRequest(plan, plan.Context?.ServerName ?? ServerName))) return;
if (plan.Destructive && !_shell.Services.Dialogs.Confirm(ReplaceRequest(plan))) return;
IsBusy = true;
await _engine.EnqueueIntegrateAsync(jobs, plan, CancellationToken.None);
}
@@ -808,11 +833,24 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
await LoadAsync();
}
/// <summary>
/// The second versions <paramref name="version"/> steps keep beside their pair: a version step whose photo has a
/// <paramref name="trash"/> step on the same side replaces it instead (This PC wins, Server wins, Other one wins).
/// </summary>
internal static int KeptVersions(IReadOnlyList<PhotoStep> steps, PhotoAction version, PhotoAction trash)
{
var replaced = steps.Where(s => s.Action == trash).Select(s => s.Key).ToHashSet(StringComparer.Ordinal);
return steps.Count(s => s.Action == version && !replaced.Contains(s.Key));
}
/// <summary>
/// "Replace photos?" (design §8.5): the losing versions under the side that loses them ("On this PC", "On Studio NAS"),
/// each side's last copies named first, every photo once.
/// </summary>
internal static ConfirmRequest ReplaceRequest(IntegratePlan plan, string? server = null)
internal ConfirmRequest ReplaceRequest(IntegratePlan plan) => ReplaceRequest(plan, plan.Context?.ServerName ?? ServerName);
/// <inheritdoc cref="ReplaceRequest(IntegratePlan)"/>
internal static ConfirmRequest ReplaceRequest(IntegratePlan plan, string? server)
{
var trashed = plan.Photos.Where(p => p.Action is PhotoAction.TrashHere or PhotoAction.TrashThere).ToList();
var name = server ?? plan.Context?.ServerName ?? string.Empty;
@@ -836,6 +874,14 @@ public sealed class CopyDialogViewModel : ArchiveDialogViewModel
var drop = plan.KeepId == Copy.LocalId ? There : Here;
var only = _review?.Photos.Of(plan.KeepId == Copy.LocalId ? PhotoClass.OnlyThere : PhotoClass.OnlyHere).Count() ?? 0;
var facts = new List<string> { Loc.Plural("Server.Copies.Plan.DropToTrash", drop.Photos, Formatting.Bytes(drop.Bytes)) };
// The kept sequence's own versions the other's replace go to its trash too: named, the last copies among them first.
var lastKeys = plan.LastCopies.Where(l => l.Side == CopySide.ThisPc).Select(l => l.Key).ToHashSet(StringComparer.Ordinal);
var replaced = plan.Photos.Where(p => p.Action == PhotoAction.TrashHere).ToList();
if (replaced.Count > 0)
{
facts.Add(Loc.Plural("Server.Copies.Confirm.Merge.Replaced", replaced.Count, keep.Where));
facts.AddRange(replaced.Where(p => !lastKeys.Contains(p.Key) && !lastKeys.Contains(p.Sha256 ?? string.Empty)).Select(p => " " + p.FileName));
}
if (only > 0) facts.Add(Loc.Plural("Server.Copies.Confirm.Merge.OnlyHere", only, drop.Where));
if (plan.Renders.Count > 0) facts.Add(Loc.Plural("Server.Copies.Plan.Renders", plan.Renders.Count));
if (plan.Projects.Count > 0) facts.Add(Loc.Plural("Server.Copies.Plan.Projects", plan.Projects.Count));
+73 -34
View File
@@ -27,6 +27,18 @@
<Setter Property="ToolTip" Value="{Binding ToolTip}" />
</Style>
<!-- A plan line reads as text to act on, not as a disabled one: the ring stays, the words take the text colour (a
style trigger outranks the glyph template's Queued colour); warnings keep theirs. -->
<Style x:Key="Status.PlanLine" TargetType="ui:StatusGlyph" BasedOn="{StaticResource {x:Type ui:StatusGlyph}}">
<Setter Property="FontSize" Value="12" />
<Setter Property="Margin" Value="0,0,0,4" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsWarning}" Value="False">
<Setter Property="Foreground" Value="{DynamicResource Brush.Text}" />
</DataTrigger>
</Style.Triggers>
</Style>
<DataTemplate DataType="{x:Type cp:CopyDialogViewModel}">
<Border Style="{StaticResource Border.Dialog}" Width="920" MaxHeight="600">
<Grid>
@@ -73,24 +85,36 @@
<ComboBox Width="170" ItemsSource="{Binding Policies}" SelectedItem="{Binding Policy}" DisplayMemberPath="Label" ToolTip="{Binding PolicyToolTip}"
ItemContainerStyle="{StaticResource ComboBoxItem.Option}" AutomationProperties.Name="{l:Loc Server.Copies.Policy.Label}" />
</StackPanel>
<ListBox Grid.Row="1" ItemsSource="{Binding Classes}" SelectedItem="{Binding SelectedClass}" ItemContainerStyle="{StaticResource ListBoxItem.CopyClass}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" AutomationProperties.Name="{l:Loc Server.Copies.Part.Photos}" Margin="0,0,14,0">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type cp:CopyClassRow}">
<Grid Height="28">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="56" />
<ColumnDefinition Width="70" />
</Grid.ColumnDefinitions>
<ui:StatusGlyph Kind="{Binding Kind}" Text="{Binding Text}" FontSize="12" VerticalAlignment="Center" />
<TextBlock Grid.Column="1" Text="{Binding CountText}" TextAlignment="Right" VerticalAlignment="Center" Typography.NumeralAlignment="Tabular" />
<TextBlock Grid.Column="2" Text="{Binding HereBytesText}" TextAlignment="Right" VerticalAlignment="Center" Foreground="{DynamicResource Brush.TextMuted}"
Typography.NumeralAlignment="Tabular" FontSize="12" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<DockPanel Grid.Row="1" Margin="0,0,14,0">
<!-- Column headings: the class, how many photos, their size (on the side that holds them). -->
<Grid DockPanel.Dock="Top" Margin="15,0,15,4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="56" />
<ColumnDefinition Width="70" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" Text="{l:Loc Server.Copies.Part.Photos}" Style="{StaticResource Text.ColumnHeader}" TextAlignment="Right" TextTrimming="CharacterEllipsis" />
<TextBlock Grid.Column="2" Text="{l:Loc Server.Copies.Photo.Size}" Style="{StaticResource Text.ColumnHeader}" TextAlignment="Right" TextTrimming="CharacterEllipsis" />
</Grid>
<ListBox ItemsSource="{Binding Classes}" SelectedItem="{Binding SelectedClass}" ItemContainerStyle="{StaticResource ListBoxItem.CopyClass}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" AutomationProperties.Name="{l:Loc Server.Copies.Part.Photos}">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type cp:CopyClassRow}">
<Grid Height="28">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="56" />
<ColumnDefinition Width="70" />
</Grid.ColumnDefinitions>
<ui:StatusGlyph Kind="{Binding Kind}" Text="{Binding Text}" FontSize="12" VerticalAlignment="Center" />
<TextBlock Grid.Column="1" Text="{Binding CountText}" TextAlignment="Right" VerticalAlignment="Center" Typography.NumeralAlignment="Tabular" />
<TextBlock Grid.Column="2" Text="{Binding BytesText}" ToolTip="{Binding BytesToolTip}" TextAlignment="Right" VerticalAlignment="Center"
Foreground="{DynamicResource Brush.TextMuted}" Typography.NumeralAlignment="Tabular" FontSize="12" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DockPanel>
<!-- Bring all / Bring none, All: keep both, To trash…, Delete on server…: above the list they act on. -->
<WrapPanel Grid.Column="1" VerticalAlignment="Center" Margin="0,0,0,8">
<Button Style="{StaticResource Button.Link}" Content="{l:Loc Server.Copies.Photo.BringAll}" Command="{Binding BringAllCommand}"
@@ -114,22 +138,23 @@
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type cp:CopyPhotoRow}">
<Grid MinHeight="28" ToolTip="{Binding ToolTip}">
<!-- A Different photo is on both sides: under Choose each its side cell gives way to the name (the choice says the side). -->
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="150" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="80" />
<ColumnDefinition Width="110" />
<ColumnDefinition Width="140" />
<ColumnDefinition Width="*" MinWidth="110" />
<ColumnDefinition Width="72" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<CheckBox IsChecked="{Binding Bring}" ToolTip="{l:Loc Tooltips.Server.Copies.Bring}" AutomationProperties.Name="{Binding BringAccessibleName}"
VerticalAlignment="Center" Margin="0,0,8,0" Visibility="{Binding CanBring, Converter={StaticResource CopyBoolToVisibility}}" />
<TextBlock Grid.Column="1" Text="{Binding TimeText}" VerticalAlignment="Center" Typography.NumeralAlignment="Tabular" FontSize="12" />
<TextBlock Grid.Column="1" Text="{Binding TimeText}" VerticalAlignment="Center" Typography.NumeralAlignment="Tabular" FontSize="12" TextTrimming="CharacterEllipsis" />
<TextBlock Grid.Column="2" Text="{Binding Name}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" FlowDirection="LeftToRight" FontSize="12" />
<TextBlock Grid.Column="3" Text="{Binding SizeText}" VerticalAlignment="Center" TextAlignment="Right" Typography.NumeralAlignment="Tabular" FontSize="12" />
<TextBlock Grid.Column="4" Text="{Binding SideText}" VerticalAlignment="Center" Foreground="{DynamicResource Brush.TextMuted}" Margin="10,0,0,0"
TextTrimming="CharacterEllipsis" FontSize="12" />
<ComboBox Grid.Column="5" Width="150" ItemsSource="{Binding Choices}" SelectedItem="{Binding Choice}" DisplayMemberPath="Label"
<TextBlock Grid.Column="4" Width="110" Text="{Binding SideText}" VerticalAlignment="Center" Foreground="{DynamicResource Brush.TextMuted}" Margin="10,0,0,0"
TextTrimming="CharacterEllipsis" FontSize="12" Visibility="{Binding CanChoose, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
<ComboBox Grid.Column="5" Width="150" Margin="10,0,0,0" ItemsSource="{Binding Choices}" SelectedItem="{Binding Choice}" DisplayMemberPath="Label"
ItemContainerStyle="{StaticResource ComboBoxItem.Option}" ToolTip="{l:Loc Tooltips.Server.Copies.Version}"
AutomationProperties.Name="{Binding ChoiceAccessibleName}" Visibility="{Binding CanChoose, Converter={StaticResource CopyBoolToVisibility}}" />
<Button Grid.Column="5" Style="{StaticResource Button.Row}" Content="{l:Loc Server.Copies.Action.Drop}" Command="{Binding DropCommand}"
@@ -144,16 +169,30 @@
</Grid>
<!-- Details: one line per difference, nothing preselected. -->
<Grid Visibility="{Binding IsDetails, Converter={StaticResource CopyBoolToVisibility}}">
<Grid Visibility="{Binding IsDetails, Converter={StaticResource CopyBoolToVisibility}}" Grid.IsSharedSizeScope="True">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Margin="0,0,0,8" Visibility="{Binding HasDetails, Converter={StaticResource CopyBoolToVisibility}}">
<Button Style="{StaticResource Button.Link}" Content="{Binding AllHereText}" Command="{Binding AllHereCommand}" ToolTip="{l:Loc Tooltips.Server.Copies.Detail.All}" Margin="0,0,14,0" />
<Button Style="{StaticResource Button.Link}" Content="{Binding AllThereText}" Command="{Binding AllThereCommand}" ToolTip="{l:Loc Tooltips.Server.Copies.Detail.All}" />
<Button Style="{StaticResource Button.Link}" Content="{Binding AllHereText}" Command="{Binding AllHereCommand}" ToolTip="{Binding AllHereToolTip}" Margin="0,0,14,0" />
<Button Style="{StaticResource Button.Link}" Content="{Binding AllThereText}" Command="{Binding AllThereCommand}" ToolTip="{Binding AllThereToolTip}" />
</StackPanel>
<ItemsControl Grid.Row="1" ItemsSource="{Binding Details}" Focusable="False" Visibility="{Binding HasDetails, Converter={StaticResource CopyBoolToVisibility}}">
<!-- Whose value each column holds: this PC and the server, or the kept sequence and the other (they follow the kept one). -->
<Grid Grid.Row="1" Margin="0,0,0,6" Visibility="{Binding HasDetails, Converter={StaticResource CopyBoolToVisibility}}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="180" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" SharedSizeGroup="CopyDetailChoice" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" Text="{Binding DetailHereHeading}" ToolTip="{Binding DetailHereHeading}" Style="{StaticResource Text.ColumnHeader}"
TextTrimming="CharacterEllipsis" Margin="10,0,0,0" />
<TextBlock Grid.Column="2" Text="{Binding DetailThereHeading}" ToolTip="{Binding DetailThereHeading}" Style="{StaticResource Text.ColumnHeader}"
TextTrimming="CharacterEllipsis" Margin="10,0,0,0" />
</Grid>
<ItemsControl Grid.Row="2" ItemsSource="{Binding Details}" Focusable="False" Visibility="{Binding HasDetails, Converter={StaticResource CopyBoolToVisibility}}">
<ItemsControl.Template>
<ControlTemplate TargetType="ItemsControl">
<ScrollViewer VerticalScrollBarVisibility="Auto" Focusable="False">
@@ -168,7 +207,7 @@
<ColumnDefinition Width="180" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" SharedSizeGroup="CopyDetailChoice" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Label}" Style="{StaticResource Text.DialogLabel}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" ToolTip="{Binding Label}" />
<TextBlock Grid.Column="1" Text="{Binding HereText}" ToolTip="{Binding HereToolTip}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" Margin="10,0,0,0" />
@@ -181,7 +220,7 @@
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<TextBlock Grid.Row="1" Text="{Binding DetailsEmptyText}" Foreground="{DynamicResource Brush.TextMuted}"
<TextBlock Grid.Row="2" Text="{Binding DetailsEmptyText}" Foreground="{DynamicResource Brush.TextMuted}"
Visibility="{Binding DetailsEmptyText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
</Grid>
@@ -257,7 +296,7 @@
<ItemsControl ItemsSource="{Binding HereLines}" Focusable="False">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type cp:CopyPlanLine}">
<ui:StatusGlyph Kind="{Binding Kind}" Text="{Binding Text}" ToolTip="{Binding ShownToolTip}" FontSize="12" Margin="0,0,0,4" />
<ui:StatusGlyph Kind="{Binding Kind}" Text="{Binding Text}" ToolTip="{Binding ShownToolTip}" Style="{StaticResource Status.PlanLine}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
@@ -267,7 +306,7 @@
<ItemsControl ItemsSource="{Binding ThereLines}" Focusable="False">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type cp:CopyPlanLine}">
<ui:StatusGlyph Kind="{Binding Kind}" Text="{Binding Text}" ToolTip="{Binding ShownToolTip}" FontSize="12" Margin="0,0,0,4" />
<ui:StatusGlyph Kind="{Binding Kind}" Text="{Binding Text}" ToolTip="{Binding ShownToolTip}" Style="{StaticResource Status.PlanLine}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
@@ -180,10 +180,10 @@ public sealed class CopyListViewModel : ObservableObject, IDisposable
}
/// <summary>Opens the Compare dialog of the pair the sequence is in (Library › Compare…); false when it is in none.</summary>
public bool Compare(Guid sequenceId)
public bool Compare(Guid sequenceId, PhotoClass? photos = null)
{
if (_pairs.FirstOrDefault(p => p.Copy.Id == PairOf(sequenceId)?.Id) is not { } pair) return false;
Open(pair, CopyDialogPart.Photos);
Open(pair, CopyDialogPart.Photos, photos);
return true;
}
@@ -431,7 +431,7 @@ public sealed class CopyListViewModel : ObservableObject, IDisposable
private void OnJobChanged(Job job)
{
if (job.Kind is not (JobKind.Integrate or JobKind.MergeSequences)) return;
if (!Follows(job.Kind)) return;
Dispatch(() =>
{
foreach (var row in Rows.Where(r => r.Copy.JobId == job.Id)) row.UpdateJob(job.State, job.ProgressDone, job.ProgressTotal);
@@ -441,13 +441,16 @@ public sealed class CopyListViewModel : ObservableObject, IDisposable
private void OnProgress(JobProgressInfo info)
{
if (info.Kind is not JobKind.Integrate) return;
if (!Follows(info.Kind)) return;
Dispatch(() =>
{
foreach (var row in Rows.Where(r => r.Copy.JobId == info.JobId)) row.UpdateJob(JobState.Running, info.Done, info.Total);
});
}
/// <summary>The jobs a pair's row follows: an Integrate, and a Merge, whose steps come through Progress only (MergeJobHandler).</summary>
internal static bool Follows(JobKind kind) => kind is JobKind.Integrate or JobKind.MergeSequences;
private static void Dispatch(Action action)
{
if (System.Windows.Application.Current?.Dispatcher is not { } dispatcher || dispatcher.CheckAccess()) action();
+59 -3
View File
@@ -9,17 +9,73 @@ using Chronos.Ui.Mvvm;
namespace Chronos.App.Server.Copies;
/// <summary>A line of the Photos part's class table: glyph and class, count, bytes on each side, what it means.</summary>
public sealed class CopyClassRow(PhotoClassTotal total) : ObservableObject
/// <summary>
/// A line of the Photos part's class table: glyph and class, count, size (this side's, else the other side's; both in the
/// tooltip when both sides hold bytes), and what the run does with it under the chosen policy.
/// </summary>
public sealed class CopyClassRow(PhotoClassTotal total, CopyPhotoPolicy policy = CopyPhotoPolicy.Union, bool isMerge = false) : ObservableObject
{
private CopyPhotoPolicy _policy = policy;
private bool _swapped;
public PhotoClass Class { get; } = total.Class;
public StatusKind Kind => CopyText.ClassKind(Class);
public string Text => CopyText.Class(Class);
public string CountText => Formatting.Count(total.Count);
public string HereBytesText => total.HereBytes > 0 ? Formatting.Bytes(total.HereBytes) : string.Empty;
public string ThereBytesText => total.ThereBytes > 0 ? Formatting.Bytes(total.ThereBytes) : string.Empty;
public string ToolTip => CopyText.ClassToolTip(Class);
/// <summary>The size cell: this side's bytes, or the other side's when this side holds none (Only there, Deleted here).</summary>
public string BytesText => total.HereBytes > 0 ? HereBytesText : ThereBytesText;
/// <summary>"This PC 51.4 MB · Server 51.8 MB" when both sides hold bytes (Different); otherwise the side the cell shows.</summary>
public string? BytesToolTip
{
get
{
var here = total.HereBytes > 0 ? Side(true) + " " + HereBytesText : null;
var there = total.ThereBytes > 0 ? Side(false) + " " + ThereBytesText : null;
return here is null && there is null ? null : string.Join(Loc.Separator, new[] { here, there }.Where(s => s is not null));
}
}
/// <summary>The policy the dialog runs with; the tooltip follows it.</summary>
public CopyPhotoPolicy Policy
{
get => _policy;
set
{
if (Set(ref _policy, value)) OnPropertyChanged(nameof(ToolTip));
}
}
/// <summary>A merge keeping the pair's other sequence: this PC's side is the dropped one.</summary>
public bool Swapped
{
get => _swapped;
set
{
if (!Set(ref _swapped, value)) return;
OnPropertyChanged(nameof(ToolTip));
OnPropertyChanged(nameof(BytesToolTip));
}
}
public string ToolTip => CopyText.ClassToolTip(Oriented, _policy, isMerge);
public int Count => total.Count;
/// <summary>The class seen from the kept sequence (a swapped merge reads Only here as the other's photos).</summary>
private PhotoClass Oriented => !isMerge || !_swapped ? Class : Class switch
{
PhotoClass.OnlyHere => PhotoClass.OnlyThere,
PhotoClass.OnlyThere => PhotoClass.OnlyHere,
PhotoClass.DeletedHere => PhotoClass.DeletedThere,
PhotoClass.DeletedThere => PhotoClass.DeletedHere,
_ => Class,
};
private string Side(bool here) => Loc.L(isMerge ? (here != _swapped ? "Server.Copies.Detail.Kept" : "Server.Copies.Detail.Other")
: here ? "Server.Copies.Detail.ThisPc" : "Server.Copies.Detail.Server");
}
/// <summary>
+1 -1
View File
@@ -82,7 +82,7 @@ public sealed class CopyRow : ObservableObject
: string.Join(Loc.Separator, _view.Here.Title, _view.There.Title);
public string HereText => CopyText.Where(_view.Here, isServer: false);
public string ThereText => CopyText.Where(_view.There, isServer: Copy.Kind == CopyKind.LocalServer);
public string ThereText => CopyText.Where(_view.There, isServer: Copy.Kind == CopyKind.LocalServer, Copy.RemoteGone);
public StatusKind StateKind => CopyText.State(Copy, _rights.ServerName, _progress).Kind;
public string StateText => CopyText.State(Copy, _rights.ServerName, _progress).Text;
+2 -1
View File
@@ -90,7 +90,8 @@ public static class CopyScenes
if (await ShowAsync(shell, "server-copies-plan") is not { } dialog) return null;
dialog.Policy = dialog.Policies.First(o => o.Value == CopyPhotoPolicy.ThisPcWins);
await dialog.PlanNowAsync();
var request = dialog.Plan is { } plan ? CopyDialogViewModel.ReplaceRequest(plan) : null;
// Worded as the dialog words it: the plan's server name, else the signed-in one's.
var request = dialog.Plan is { } plan ? dialog.ReplaceRequest(plan) : null;
shell.Server.CloseDialog(dialog);
return request;
}
+40 -12
View File
@@ -54,17 +54,23 @@ public static class CopyText
CopyState.KeptApart => (StatusKind.Offline, Loc.L("Server.Copies.State.KeptApart"),
Loc.L("Tooltips.Server.Copies.State.KeptApart", Formatting.Date(copy.AnsweredAt ?? copy.UpdatedAt))),
CopyState.Linked => (StatusKind.Synced, Loc.L("Server.Copies.State.Linked"), Loc.L("Tooltips.Server.Copies.State.Linked")),
// The share in the cell (it fits the column in both languages); "1,234 of 2,400" in the tooltip.
CopyState.Integrating => (StatusKind.Running,
Loc.L("Server.Copies.State.Integrating", Percent(progress)),
progress is { Total: > 0 } p
? string.Join(Environment.NewLine, Loc.L("Tooltips.Server.Copies.State.Integrating"),
Loc.L("Server.Copies.State.Progress", Formatting.Count(p.Done), Formatting.Count(p.Total)))
: Loc.L("Tooltips.Server.Copies.State.Integrating")),
// The share in the cell (it fits the column in both languages); "1,234 of 2,400" in the tooltip. A pair of this
// PC's archives is being merged, not integrated.
CopyState.Integrating => Running(copy.Kind == CopyKind.LocalLocal ? "Merging" : "Integrating", progress),
// An Integrate that left photos out moves new photos only on Upload and Download (IntegrateJobHandler).
_ when copy.Kind == CopyKind.LocalServer && !copy.AutoPhotos =>
(StatusKind.Done, Loc.L("Server.Copies.State.Integrated"), Loc.L("Tooltips.Server.Copies.State.IntegratedByHand")),
_ => (StatusKind.Done, Loc.L("Server.Copies.State.Integrated"), Loc.L("Tooltips.Server.Copies.State.Integrated")),
};
}
private static (StatusKind, string, string) Running(string word, (long Done, long Total)? progress) => (StatusKind.Running,
Loc.L("Server.Copies.State." + word, Percent(progress)),
progress is { Total: > 0 } p
? string.Join(Environment.NewLine, Loc.L("Tooltips.Server.Copies.State." + word),
Loc.L("Server.Copies.State.Progress", Formatting.Count(p.Done), Formatting.Count(p.Total)))
: Loc.L("Tooltips.Server.Copies.State." + word));
/// <summary>How far an Integrate or Merge job came, in whole per cent ("51"); "0" before it reports.</summary>
private static string Percent((long Done, long Total)? progress) => progress is { Total: > 0 } p
? Math.Clamp(p.Done * 100 / p.Total, 0, 100).ToString("0", Loc.Culture)
@@ -74,9 +80,12 @@ public static class CopyText
public static string SharedPercent(CopyScore score) =>
Math.Round(Math.Clamp(score.Containment, 0, 1000) / 10.0).ToString("0", Loc.Culture);
/// <summary>"Main archive · 1,204 photos": where one side of a pair lies.</summary>
public static string Where(CopyFacts facts, bool isServer) =>
Loc.Plural(isServer ? "Server.Copies.Where.Server" : "Server.Copies.Where.Archive", facts.Photos, facts.Where);
/// <summary>
/// "Main archive · 1,204 photos": where one side of a pair lies; the server's name alone once it deleted its sequence
/// (<paramref name="gone"/>: no count is known, and "0 photos" would read as an empty sequence).
/// </summary>
public static string Where(CopyFacts facts, bool isServer, bool gone = false) => gone && facts.Where.Length > 0 ? facts.Where
: Loc.Plural(isServer ? "Server.Copies.Where.Server" : "Server.Copies.Where.Archive", facts.Photos, facts.Where);
/// <summary>
/// "Main archive · 1,204 photos · 18.2 GB": a side of the dialog's header; "Lighthouse · Main archive · 1,204 photos ·
@@ -159,7 +168,26 @@ public static class CopyText
/// <summary>The word of a photo class ("Only here").</summary>
public static string Class(PhotoClass c) => Loc.L("Server.Copies.Class." + c);
public static string ClassToolTip(PhotoClass c) => Loc.L("Tooltips.Server.Copies.Class." + c);
/// <summary>
/// What a class means and what the run does with it under <paramref name="policy"/>: Different by the winning side or
/// the per-photo choice, Only here and Only there ticked under Choose each, and a merge's own wording (the other
/// sequence's photos all come in; the kept one's stay). A merge's classes are read from the kept sequence's side.
/// </summary>
public static string ClassToolTip(PhotoClass c, CopyPhotoPolicy policy = CopyPhotoPolicy.Union, bool isMerge = false)
{
var variant = (c, policy) switch
{
(PhotoClass.Differs, CopyPhotoPolicy.ThisPcWins) => isMerge ? ".KeptWins" : ".ThisPcWins",
(PhotoClass.Differs, CopyPhotoPolicy.OtherWins) => isMerge ? ".OtherCopyWins" : ".OtherWins",
(PhotoClass.Differs, CopyPhotoPolicy.ChoosePerPhoto) => ".Choose",
(PhotoClass.Differs, _) when isMerge => ".Merge",
(PhotoClass.OnlyHere or PhotoClass.OnlyThere, _) when isMerge => ".Merge",
(PhotoClass.OnlyHere or PhotoClass.OnlyThere, CopyPhotoPolicy.ChoosePerPhoto) => ".Choose",
(PhotoClass.SameUnhashed, _) when !isMerge => ".Integrate",
_ => string.Empty,
};
return Loc.L("Tooltips.Server.Copies.Class." + c + variant);
}
/// <summary>The glyph of a photo class: what an Integrate settles by itself is fine; what waits for a choice is a warning.</summary>
public static StatusKind ClassKind(PhotoClass c) => c switch
@@ -177,7 +205,7 @@ public static class CopyText
CopyBlock.NeedsNewerServer => Loc.L("Errors.Copies.NeedsNewerServer", server ?? string.Empty),
CopyBlock.LinkTaken => Loc.L("Errors.Copies.LinkTaken", title, server ?? string.Empty),
CopyBlock.NoSpace => Loc.L("Errors.Copies.NoSpace", title, need ?? string.Empty),
CopyBlock.ArchiveOffline or CopyBlock.FolderMoved or CopyBlock.ChangedFile => Loc.L("Errors.Copies." + block, title),
CopyBlock.ArchiveOffline or CopyBlock.FolderMoved or CopyBlock.ChangedFile or CopyBlock.DamagedPhotos => Loc.L("Errors.Copies." + block, title),
CopyBlock.UnsentWorkspace => Loc.L("Errors.Copies.Unsent", title),
CopyBlock.BothLinked => Loc.L("Errors.Copies.BothLinked", server ?? string.Empty),
CopyBlock.TrashBlocked => Loc.L("Errors.Copies.TrashBlocked", title, need ?? string.Empty),
+1 -1
View File
@@ -22,7 +22,7 @@ public sealed class SyncRowAction : ObservableObject
}
public SyncAction Action { get; }
public string Text => Action == SyncAction.Compare ? Loc.L("Server.Copies.Action.Compare") : Loc.L("Server.Sync.Action." + Action);
public string Text => Action is SyncAction.Compare or SyncAction.Review ? Loc.L("Server.Copies.Action." + Action) : Loc.L("Server.Sync.Action." + Action);
public ICommand Command => _command;
public string ToolTip
@@ -435,6 +435,9 @@ public sealed class SyncTableViewModel : ObservableObject, IDisposable
case SyncAction.Compare:
Copies.Compare(entry.Local?.Id ?? entry.Id);
return;
case SyncAction.Review:
Copies.Compare(entry.Local?.Id ?? entry.Id, PhotoClass.DeletedThere);
return;
case SyncAction.Upload:
await service.EnqueueUploadAsync(engine, server, entry.Local!);
break;
+17 -2
View File
@@ -46,6 +46,9 @@ public enum SyncAction
/// <summary>Compare the row's sequence with its match (owner review 6, #73).</summary>
Compare,
/// <summary>Open Compare on the photos the match deleted (design §6.2: "deleted there · n" with Review).</summary>
Review,
}
/// <summary>
@@ -196,6 +199,12 @@ public static class SyncText
? (StatusKind.Offline, Loc.L("Server.Sync.State.KeptHere"), Loc.L("Tooltips.Server.Copies.State.KeptHere"))
: (StatusKind.Warning, Loc.L("Server.Sync.State.RemoteGone"), Loc.L("Tooltips.Server.Copies.State.RemoteGone"));
}
// The match deleted photos this side still holds: the pair row's words, with Review among the actions.
if (DeletedThere(mark) is > 0 and var deleted)
{
var key = mark.Copy!.Kind == Data.Copies.CopyKind.LocalLocal ? "Server.Copies.State.DeletedOther" : "Server.Copies.State.DeletedThere";
return (StatusKind.Warning, Loc.L(key, Formatting.Count(deleted)), Loc.Plural("Tooltips.Server.Copies.State.DeletedThere", deleted));
}
if (mark.NotSent is { Count: >= SyncAgent.NotSentAfter } failure)
return (StatusKind.Warning, Loc.L("Server.Sync.State.NotSent"), Loc.L("Tooltips.Server.Sync.State.NotSent", failure.Reason));
// A match between two of this PC's archives names the other archive, not the server.
@@ -204,22 +213,27 @@ public static class SyncText
? Loc.L("Tooltips.Library.Status.CopyFoundLocal", mark.OtherWhere ?? string.Empty)
: Loc.L("Tooltips.Server.Sync.State.CopyFound", mark.ServerName ?? mark.Copy.Server ?? string.Empty));
if (mark.Skipped is { } why && entry.Status == SyncStatus.LocalOnly)
return (StatusKind.Offline, Loc.L("Server.Sync.State.Skipped"), Loc.L("Tooltips.Server.Sync.State.Skipped", Loc.L("Tooltips.Server.Sync.Skip." + why)));
return (StatusKind.Warning, Loc.L("Server.Sync.State.Skipped"), Loc.L("Tooltips.Server.Sync.State.Skipped", Loc.L("Tooltips.Server.Sync.Skip." + why)));
return State(entry);
}
/// <summary>
/// The row's buttons with its match (design §8.1): a sequence in an unanswered pair offers Compare… first, then its usual
/// buttons; a linked one offers Compare… last.
/// buttons; a linked one offers Compare… last, and Review… after it when the match deleted photos.
/// </summary>
public static IReadOnlyList<SyncAction> Actions(SyncEntry entry, SyncRights rights, SyncMark mark)
{
var actions = Actions(entry, rights);
if (entry.Transfer is not null || mark.Copy is null || mark.Copy.RemoteGone) return actions;
if (mark.IsCandidate) return [SyncAction.Compare, .. actions];
if (DeletedThere(mark) > 0) return [.. actions, SyncAction.Compare, SyncAction.Review];
return entry.Link is not null ? [.. actions, SyncAction.Compare] : actions;
}
/// <summary>The photos a linked or integrated match deleted that this side still holds; 0 otherwise.</summary>
private static int DeletedThere(SyncMark mark) =>
mark.Copy is { RemoteGone: false, State: Data.Copies.CopyState.Linked or Data.Copies.CopyState.Integrated } copy ? copy.Score.DeletedThere : 0;
/// <summary>The label of a detail line of the Compare dialog ("Deflicker window"); "Other setting" when unknown.</summary>
public static string DetailLabel(string path)
{
@@ -417,6 +431,7 @@ public static class SyncText
SyncAction.SendExports => Loc.Plural("Tooltips.Server.Sync.SendExports", entry.Link!.ExportsToSend, Formatting.Bytes(Size(entry, action))),
SyncAction.OpenInWorkspace when !rights.KeepsProjects => Loc.L("Tooltips.Server.Sync.OpenInWorkspace.NoProjects"),
SyncAction.Compare => Loc.L("Tooltips.Server.Copies.Compare"),
SyncAction.Review => Loc.L("Tooltips.Server.Copies.Review"),
_ => Loc.L("Tooltips.Server.Sync." + action),
};
+25 -11
View File
@@ -4,6 +4,7 @@ using Chronos.App.Infrastructure;
using Chronos.Core.Diagnostics;
using Chronos.Core.Model;
using Chronos.Data.Jobs;
using Chronos.Data.Sync;
using Chronos.Data.Workspaces;
namespace Chronos.App.Server;
@@ -12,9 +13,11 @@ namespace Chronos.App.Server;
/// "Pause metered transfers" (Server.html): while <see cref="AppSettings.PauseUploadsOnMetered"/> is on and Windows reports
/// the connection as metered, the transfers with a server are paused (a running one stops after its current chunk or file
/// and keeps its checkpoint): upload jobs, the sync's downloads, and since phase 5c the workspace's copies from a server and
/// its renders sent to one, and since owner review 6 the integration of a pair with a server sequence (<see cref="Holds"/>); a copy from or a send to this PC's archive is never held. They are resumed when the connection
/// is no longer metered or the option goes off. Only the jobs it paused are resumed. Checked when the network or one of
/// those jobs changes, and every minute.
/// its renders sent to one, and since owner review 6 the integration of a pair with a server sequence (<see cref="Holds"/>); a copy from or a send to this PC's archive is never held.
/// The automatic transfers of an integrated pair's new photos are held on a metered connection even with the option off
/// (owner review 6, Q6; <see cref="HeldNow"/>). They are resumed when the connection is no longer metered or the option
/// goes off (for the jobs only it holds). Only the jobs it paused are resumed. Checked when the network or one of those
/// jobs changes, and every minute.
/// </summary>
public sealed class UploadHold : IDisposable
{
@@ -55,8 +58,6 @@ public sealed class UploadHold : IDisposable
if (_engine is not null) _engine.JobChanged -= OnJobChanged;
}
private bool Holding => _services.Settings.PauseUploadsOnMetered && MeteredNetwork.IsMetered();
private void OnNetworkChanged(object? sender, EventArgs e) => Request();
private void OnJobChanged(Job job)
@@ -86,32 +87,45 @@ public sealed class UploadHold : IDisposable
};
}
/// <summary>
/// Whether <paramref name="job"/> is held now: on a metered connection, a job <see cref="Holds"/> names while the option
/// is on, and an automatic transfer of an integrated pair's new photos whatever the option says (owner review 6, Q6:
/// new photos move by themselves "paused on metered connections").
/// </summary>
internal static bool HeldNow(Job job, bool metered, bool optionOn) =>
metered && Holds(job) && (optionOn || SyncService.IsAutomaticTransfer(job));
private async Task ApplyAsync()
{
if (_engine is not { } engine || _services.Database is not { } db) return;
await _gate.WaitAsync();
try
{
if (Holding)
// Read once per pass: the connection's cost and the option.
var metered = MeteredNetwork.IsMetered();
var optionOn = _services.Settings.PauseUploadsOnMetered;
if (metered)
{
foreach (var state in new[] { JobState.Queued, JobState.Running })
{
foreach (var kind in Kinds)
{
foreach (var job in (await db.Jobs.ListAsync(state, kind, 500)).Items.Where(Holds))
foreach (var job in (await db.Jobs.ListAsync(state, kind, 500)).Items.Where(j => HeldNow(j, metered, optionOn)))
{
await engine.PauseAsync(job.Id);
_held.Add(job.Id);
}
}
}
return;
}
foreach (var id in _held)
// The jobs this hold paused that no longer need holding (the connection, or the option for a job only it holds) resume.
foreach (var id in _held.ToList())
{
if (await db.Jobs.GetAsync(id) is { State: JobState.Paused }) await engine.ResumeAsync(id);
var job = await db.Jobs.GetAsync(id);
if (job is not null && HeldNow(job, metered, optionOn)) continue;
if (job is { State: JobState.Paused }) await engine.ResumeAsync(id);
_held.Remove(id);
}
_held.Clear();
}
catch (Data.DatabaseException ex)
{
+34 -1
View File
@@ -144,6 +144,10 @@ public sealed class SequenceMerger(ChronosDatabase db, ArchiveService archives,
var losers = steps.Where(s => s.Action == PhotoAction.TrashHere).Select(s => s.FrameId!.Value).ToHashSet();
var keepHolds = here.Photos.Where(p => !p.Unusable && p.Sha256 is { Length: > 0 } && !losers.Contains(p.FrameId))
.Select(p => p.Sha256!.ToLowerInvariant()).ToHashSet(StringComparer.Ordinal);
// Photos of the other a verify flagged Corrupt (changed since import, or damaged) whose file is still there: the
// comparison leaves them out, so nothing would copy or hash-verify them before their folder goes to the trash. One
// whose content now nothing else holds (an edited photo's only copy) blocks the merge until it is resolved.
if (online && await DamagedAsync(drop, dropPaths, keepHolds, ct).ConfigureAwait(false)) blocks.Add(CopyBlock.DamagedPhotos);
var absent = new List<CopyPhotoInput>();
foreach (var frame in there.Photos.Where(p => !p.Unusable && p.Sha256 is { Length: > 0 }))
{
@@ -276,6 +280,35 @@ public sealed class SequenceMerger(ChronosDatabase db, ArchiveService archives,
return changed ? there with { Photos = photos } : null;
}
/// <summary>
/// Whether the other sequence holds a frame flagged Corrupt (not Missing) whose file is still there and whose content,
/// hashed now (in memory), neither the kept sequence (<paramref name="keepHolds"/>) nor any other sequence of this
/// index holds; an unreadable such file counts too.
/// </summary>
private async Task<bool> DamagedAsync(Guid drop, ArchivePaths dropPaths, IReadOnlySet<string> keepHolds, CancellationToken ct)
{
var flagged = (await _db.Frames.ListBySequenceAsync(drop, cancellationToken: ct).ConfigureAwait(false))
.Where(f => (f.Flags & FrameFlags.Corrupt) != 0 && (f.Flags & FrameFlags.Missing) == 0).ToList();
var hashes = new List<string>();
foreach (var frame in flagged)
{
var path = dropPaths.FromRelative(frame.RelativePath);
if (!File.Exists(path)) continue;
try
{
var sha = (await ContentHash.Sha256Async(path, null, ct).ConfigureAwait(false)).ToLowerInvariant();
if (!keepHolds.Contains(sha)) hashes.Add(sha);
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
{
return true;
}
}
if (hashes.Count == 0) return false;
var held = await _sides.HeldElsewhereAsync(hashes, [drop], ct).ConfigureAwait(false);
return hashes.Any(h => !held.Contains(h));
}
/// <summary>
/// Queues the job that applies <paramref name="plan"/>: the pair goes to <see cref="CopyState.Integrating"/> (its state
/// before kept as the previous one), the job targets the kept sequence, then the other (both held from other jobs).
@@ -326,7 +359,7 @@ public sealed class SequenceMerger(ChronosDatabase db, ArchiveService archives,
return block switch
{
CopyBlock.Busy => Loc.L("Errors.Copies.Busy"),
CopyBlock.ArchiveOffline or CopyBlock.FolderMoved or CopyBlock.ChangedFile => Loc.L("Errors.Copies." + block, dropTitle),
CopyBlock.ArchiveOffline or CopyBlock.FolderMoved or CopyBlock.ChangedFile or CopyBlock.DamagedPhotos => Loc.L("Errors.Copies." + block, dropTitle),
CopyBlock.NoSpace => Loc.L("Errors.Copies.NoSpace", keepTitle, Size(plan.CopyBytes + SpaceReserve)),
CopyBlock.BothLinked => Loc.L("Errors.Copies.BothLinked", plan.BothLinkedServer ?? string.Empty),
CopyBlock.UnsentWorkspace => Loc.L("Errors.Copies.Unsent", dropTitle),
+1 -1
View File
@@ -503,7 +503,7 @@ public sealed class CopyEngine(SyncService sync, ArchiveService archives, Integr
if (here is null && there is null) continue;
var local = await Db.Sequences.GetAsync(pair.LocalId, ct).ConfigureAwait(false);
twins.Add(new CopyTwin(pair.Id, pair.LocalId, local is null ? string.Empty : archives.GetValueOrDefault(local.ArchiveId) ?? string.Empty, here, pair.Server!,
pair.RemoteId!.Value, there));
pair.RemoteId!.Value, there, ServerName(pair.Server!)));
}
return twins;
}
+11 -1
View File
@@ -46,6 +46,12 @@ public enum CopyBlock
TrashBlocked,
KeptUnchosen,
ChangedFile,
/// <summary>Photos sent into a server sequence the account neither owns nor may edit (the server refuses that, 403).</summary>
NoAddRight,
/// <summary>The other sequence of a merge holds photos a verify flagged changed or damaged: they would go to the trash unchecked.</summary>
DamagedPhotos,
}
/// <summary>The choices of an Integrate: photo policy, per-photo choices (by photo key), per-detail sides (by path), projects.</summary>
@@ -114,7 +120,11 @@ public sealed record MergePlan(Guid CopyId, Guid KeepId, Guid DropId, MergeChoic
/// </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);
IReadOnlySet<Guid> ServerOriginalsArchives)
{
/// <summary>The signed-in account's id: it owns a server sequence whose owner it is (null: unknown, signed out).</summary>
public Guid? UserId { get; init; }
}
/// <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,
+3 -1
View File
@@ -38,5 +38,7 @@ public sealed record FoundCopyView(FoundCopy Copy, CopyFacts Here, CopyFacts The
/// <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.
/// ServerName is the name shown for Server (the key itself when no name is known).
/// </summary>
public sealed record CopyTwin(Guid CopyId, Guid LocalId, string LocalHome, string? LocalProject, string Server, Guid RemoteId, string? ServerProject);
public sealed record CopyTwin(Guid CopyId, Guid LocalId, string LocalHome, string? LocalProject, string Server, Guid RemoteId, string? ServerProject,
string ServerName);
+8 -1
View File
@@ -163,7 +163,8 @@ public sealed class FoundCopyStore(ChronosDatabase db, TimeProvider? time = null
/// <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).
/// server, is demoted to Candidate (a link re-pointed to another copy: sync_links holds one link per side and server); the
/// local copy's rows with another server sequence that answered 404 are deleted (Upload again).
/// </summary>
public Task<FoundCopy> EnsureLinkedAsync(string server, Guid remoteId, Guid localId, CancellationToken ct)
{
@@ -186,6 +187,12 @@ public sealed class FoundCopyStore(ChronosDatabase db, TimeProvider? time = null
[row.Id, false, now], ct).ConfigureAwait(false);
}
await DemoteAsync(inner, server, remoteId, localId, now, ct).ConfigureAwait(false);
// The rows of the local copy with a server sequence that server answered 404 for (design §6.3, "Upload again
// deletes the gone row"), Candidate and Kept apart included: the local copy is linked to another sequence now, and a
// gone sequence listed again is found anew.
await inner.ExecuteAsync(
$"DELETE FROM found_copies WHERE kind = 0 AND server = $1 AND local_id = $3 AND remote_id <> $2 AND remote_gone_hits >= 1 AND {Effective} <> 3",
[server, remoteId, localId], ct).ConfigureAwait(false);
return (await inner.SingleAsync($"{Select} WHERE id = $1", [row.Id], Map, ct).ConfigureAwait(false))!;
}
@@ -349,8 +349,10 @@ internal sealed class IntegrateJobHandler(SyncService sync, IntegratePlanner pla
}
try
{
var dryRun = await remote.DeleteFramesAsync(journal.RemoteId, new FrameDeleteRequest([step.FrameId], null, DryRun: true), _ct).ConfigureAwait(false);
await remote.DeleteFramesAsync(journal.RemoteId, new FrameDeleteRequest([step.FrameId], dryRun.FramesVersion, DryRun: false), _ct).ConfigureAwait(false);
// At the frames version of the manifest that showed the winner in place: a server sequence changed since (the
// winner trashed or replaced by another client) refuses the delete, and the loser stays.
await remote.DeleteFramesAsync(journal.RemoteId, new FrameDeleteRequest([step.FrameId], manifest.FramesVersion, DryRun: true), _ct).ConfigureAwait(false);
await remote.DeleteFramesAsync(journal.RemoteId, new FrameDeleteRequest([step.FrameId], manifest.FramesVersion, DryRun: false), _ct).ConfigureAwait(false);
journal.TrashedThere.Add(step.Key);
Save();
}
@@ -199,6 +199,10 @@ public sealed class IntegratePlanner(SyncService sync, CopySides sides, ProjectS
// Rights.
if (steps.Any(s => s.Action is PhotoAction.Send or PhotoAction.SendVersion) && !context.CanUpload) blocks.Add(CopyBlock.NoUploadRight);
// Sent into the server sequence: the server allows that to its owner, an admin or an account with Edit only.
var owns = context.OwnsOrAdmin || (context.UserId is { } me && dto.OwnerUserId == me);
if (steps.Any(s => s.Action is PhotoAction.Send or PhotoAction.SendVersion) && context.CanUpload && !owns && !context.CanEdit)
blocks.Add(CopyBlock.NoAddRight);
if (steps.Any(s => s.Action is PhotoAction.Fetch or PhotoAction.FetchVersion) && !context.CanFetch) blocks.Add(CopyBlock.NoFetchRight);
// Nothing left but versions whose loser stays for want of the Delete right: there is nothing to integrate.
if (dropped.Count > 0 && steps.All(s => dropped.Contains(s.Key)) && payload is null && projectSteps.Count == 0) blocks.Add(CopyBlock.NoDeleteRight);
@@ -232,6 +236,7 @@ public sealed class IntegratePlanner(SyncService sync, CopySides sides, ProjectS
CopyBlock.NoUploadRight => Loc.L("Errors.Copies.NoUploadRight"),
CopyBlock.NoFetchRight => Loc.L("Errors.Copies.NoFetchRight"),
CopyBlock.NoEditRight => Loc.L("Errors.Copies.NoEditRight"),
CopyBlock.NoAddRight => Loc.L("Errors.Copies.NoAddRight"),
CopyBlock.NoDeleteRight => Loc.L("Errors.Copies.NoDeleteRight"),
CopyBlock.LinkTaken => Loc.L("Errors.Copies.LinkTaken", title, server),
CopyBlock.NoSpace => Loc.L("Errors.Copies.NoSpace", title, Size(plan.FetchBytes + SpaceReserve)),
+11
View File
@@ -405,6 +405,17 @@ public sealed class SyncService
EnqueueAsync(engine, JobKind.Download, remoteId, title, new SyncJobParameters(server, SyncDownloadMode.Originals, archiveId, Automatic: true),
JobPriority.Background, cancellationToken);
/// <summary>
/// Whether <paramref name="job"/> is an automatic transfer of an integrated pair's new photos
/// (<see cref="EnqueueAutomaticUploadAsync"/>, <see cref="EnqueueAutomaticDownloadAsync"/>): a metered connection pauses
/// those whatever the option says (owner review 6, Q6).
/// </summary>
public static bool IsAutomaticTransfer(Job job)
{
ArgumentNullException.ThrowIfNull(job);
return SyncJobParameters.Read(job)?.IsAutomatic == true;
}
/// <summary>Queues sending the renders of a local copy the server lacks (BRIEF §14.5), unless that is already waiting or running.</summary>
public Task<Job> EnqueueSendExportsAsync(JobEngine engine, string server, Sequence local, CancellationToken cancellationToken = default) =>
EnqueueAsync(engine, JobKind.UploadCommit, local.Id, local.DisplayTitle, new SyncJobParameters(server, Upload: SyncUploadMode.Exports), JobPriority.User,
+42 -5
View File
@@ -98,12 +98,15 @@ internal sealed class SyncTransfers(SyncService sync)
// A server that files a photo it holds in another sequence into this one (owner review 6): the map's "missing on the
// server" reaches 0 once every original is in the target, not merely somewhere on the server.
var into = (await remote.CapabilitiesAsync(ct).ConfigureAwait(false)).Contains(ServerCapabilities.UploadInto);
if (into)
// An account that may upload but neither owns the target nor may edit it is refused that (403): the originals then go
// as before, each to the target unless the server holds it elsewhere (IntoRefusal).
var into = (await remote.CapabilitiesAsync(ct).ConfigureAwait(false)).Contains(ServerCapabilities.UploadInto) ? new IntoRefusal() : null;
if (into is not null)
{
// Counted already (they reached the server before the target existed): filed into it now, nothing stepped again.
foreach (var frame in heldElsewhere)
{
if (into.Refused) break;
if (await UploadFrameAsync(context, remote, target, null, paths.FromRelative(frame.RelativePath), frame, tombstones, hashes, ct, into)
.ConfigureAwait(false) is null)
skipped++;
@@ -978,8 +981,18 @@ internal sealed class SyncTransfers(SyncService sync)
/// original the index has none for goes into <paramref name="hashes"/>; known by content only now, such an original
/// the server deleted (<paramref name="tombstones"/>) is not sent back.
/// </summary>
private static Task<CompleteUploadResponse?> UploadFrameAsync(JobContext context, ISyncRemote remote, Guid? sequenceId, string? sessionKey, string path,
Frame frame, SyncTombstones tombstones, ConcurrentDictionary<Guid, string> hashes, CancellationToken cancellationToken, IntoRefusal? into) =>
UploadFrameAsync(context, remote, sequenceId, sessionKey, path, frame, tombstones, hashes, cancellationToken, into is not null, into);
/// <summary>
/// <paramref name="into"/>: through <see cref="ISyncRemote.UploadFileIntoAsync"/>; with <paramref name="fallback"/>, a
/// 403 for that (an account that neither owns the target nor may edit it) sends this original and every later one of
/// the job the plain way instead (<see cref="IntoRefusal"/>).
/// </summary>
private static async Task<CompleteUploadResponse?> UploadFrameAsync(JobContext context, ISyncRemote remote, Guid? sequenceId, string? sessionKey, string path,
Frame frame, SyncTombstones tombstones, ConcurrentDictionary<Guid, string> hashes, CancellationToken cancellationToken, bool into = false)
Frame frame, SyncTombstones tombstones, ConcurrentDictionary<Guid, string> hashes, CancellationToken cancellationToken, bool into = false,
IntoRefusal? fallback = null)
{
if (!File.Exists(path))
{
@@ -1002,11 +1015,35 @@ internal sealed class SyncTransfers(SyncService sync)
context.Log(Loc.L("Archive.Log.SyncChanged", frame.FileName));
return null;
}
if (into && sequenceId is { } target)
return await remote.UploadFileIntoAsync(path, target, sha, frame.CapturedAt, cancellationToken).ConfigureAwait(false) ?? notSent;
if (into && sequenceId is { } target && fallback is not { Refused: true })
{
try
{
return await remote.UploadFileIntoAsync(path, target, sha, frame.CapturedAt, cancellationToken).ConfigureAwait(false) ?? notSent;
}
catch (ChronosApiException ex) when (fallback is not null && ex.Status == HttpStatusCode.Forbidden
&& string.Equals(ex.Error.Code, "forbidden", StringComparison.Ordinal))
{
if (fallback.Refuse()) context.Log(Loc.L("Archive.Log.SyncIntoRefused"));
}
}
return await remote.UploadFileAsync(path, sequenceId, sessionKey, sha, frame.CapturedAt, cancellationToken).ConfigureAwait(false) ?? notSent;
}
/// <summary>
/// Whether the server refused an upload into the target to this account (owner review 6, #73): set once, by the first
/// refusal; the job's later originals go the plain way, as before the server could file into a target.
/// </summary>
private sealed class IntoRefusal
{
private int _refused;
public bool Refused => Volatile.Read(ref _refused) == 1;
/// <summary>Records the refusal; true for the first one.</summary>
public bool Refuse() => Interlocked.Exchange(ref _refused, 1) == 0;
}
/// <summary>Commits one original from staging into the local sequence (created from the server id when null).</summary>
private async Task<IngestResult> CommitAsync(Guid remoteId, Guid archiveId, Guid? sequenceId, ManifestFrame frame, string staged, string sha,
IReadOnlyDictionary<Guid, DateTime?> captured, CancellationToken cancellationToken)
@@ -111,7 +111,7 @@ public sealed class CopyScreenSmokeTests
// This PC's version wins: the server's versions go to its trash, so the confirmation is destructive.
dialog.Policy = dialog.Policies.First(o => o.Value == CopyPhotoPolicy.ThisPcWins);
await dialog.PlanNowAsync();
var replace = CopyDialogViewModel.ReplaceRequest(Assert.NotNull(dialog.Plan));
var replace = dialog.ReplaceRequest(Assert.NotNull(dialog.Plan));
Assert.True(replace.IsDestructive);
Assert.Equal(Loc.L("Server.Copies.Confirm.Replace.Title"), replace.Heading);
@@ -180,7 +180,8 @@ public sealed class CopyScreenSmokeTests
await LibraryScenes.ShowCopiesAsync(shell, CopyScenes.Alps);
var item = Assert.Contains(shell.Library.Items, i => i.HasMatch && i.Title == CopyScenes.Alps);
Assert.NotNull(item.MatchStatus);
Assert.Contains(item.Statuses, s => s == item.MatchStatus);
// Second, right after the analysis status, so a narrow card cuts the others first.
Assert.Equal(item.MatchStatus, item.Statuses[1]);
Assert.True(shell.Library.CompareItemCommand.CanExecute(item));
// A refresh builds new cards: the match status stays on them.
await shell.Library.RefreshAsync();
+126 -3
View File
@@ -1,4 +1,6 @@
using System.Globalization;
using System.IO;
using Chronos.App.Infrastructure;
using Chronos.App.Server;
using Chronos.App.Server.Copies;
using Chronos.Core.Localization;
@@ -127,7 +129,11 @@ public sealed class CopyTextTests
foreach (var c in Enum.GetValues<PhotoClass>())
{
Assert.False(string.IsNullOrWhiteSpace(CopyText.Class(c)), $"{culture}: {c}");
Assert.False(string.IsNullOrWhiteSpace(CopyText.ClassToolTip(c)), $"{culture}: {c} has a tooltip");
foreach (var policy in Enum.GetValues<CopyPhotoPolicy>())
{
foreach (var merge in new[] { false, true })
Assert.False(string.IsNullOrWhiteSpace(CopyText.ClassToolTip(c, policy, merge)), $"{culture}: {c} has a tooltip under {policy}");
}
}
foreach (var block in Enum.GetValues<CopyBlock>())
Assert.False(string.IsNullOrWhiteSpace(CopyText.Block(block, "Lighthouse", "Studio NAS", "2 GB", 2)), $"{culture}: {block}");
@@ -176,9 +182,9 @@ public sealed class CopyTextTests
Assert.Equal(Loc.L("Server.Sync.State.RemoteGone"), SyncText.State(linked, new SyncMark(Copy(CopyState.Linked, gone: true), null)).Text);
Assert.Equal(Loc.L("Server.Sync.State.KeptHere"), SyncText.State(linked, new SyncMark(Copy(CopyState.KeptApart, gone: true), null)).Text);
// Upload all local left it out: "skipped", with the reason.
// Upload all local left it out: "skipped", with the reason, under the Warning glyph (design §6.4).
var skipped = SyncText.State(entry, new SyncMark(null, UploadSkip.KeptApart));
Assert.Equal((StatusKind.Offline, Loc.L("Server.Sync.State.Skipped")), (skipped.Kind, skipped.Text));
Assert.Equal((StatusKind.Warning, Loc.L("Server.Sync.State.Skipped")), (skipped.Kind, skipped.Text));
Assert.Equal(Loc.L("Tooltips.Server.Sync.State.Skipped", Loc.L("Tooltips.Server.Sync.Skip.KeptApart")), skipped.ToolTip);
// A transfer still shows first.
var upload = new Job { Id = Guid.CreateVersion7(), Kind = JobKind.UploadCommit, State = JobState.Running };
@@ -196,6 +202,8 @@ public sealed class CopyTextTests
// The count comes first, so a trimmed cell keeps what tells two pairs apart.
Assert.True(CopyText.Where(Facts("Lighthouse", "Main archive", 1_204), isServer: false).StartsWith("1,204", StringComparison.Ordinal));
// A server that deleted its sequence is named alone, never "0 photos".
Assert.Equal("Studio NAS", CopyText.Where(Facts(string.Empty, "Studio NAS", 0), isServer: true, gone: true));
// The frame positions read as the setting they are, with the count of photos they place.
Assert.Equal(Loc.L("Server.Copies.Detail.Positions"), SyncText.DetailLabel(CopyPayload.PendingFramesPath));
@@ -247,6 +255,121 @@ public sealed class CopyTextTests
], lines);
}
[Test]
public void ThePairWordsFollowWhatTheRunReallyDoes()
{
// An Integrate that left photos out moves new photos only by hand; one that left nothing out, by itself.
Assert.Equal(Loc.L("Tooltips.Server.Copies.State.IntegratedByHand"), CopyText.State(Copy(CopyState.Integrated)).ToolTip);
Assert.Equal(Loc.L("Tooltips.Server.Copies.State.Integrated"), CopyText.State(Copy(CopyState.Integrated) with { AutoPhotos = true }).ToolTip);
// A pair of this PC's archives is merged, with the same "x of y".
var (_, text, tip) = CopyText.State(Copy(CopyState.Integrating, CopyKind.LocalLocal), progress: (1, 4));
Assert.Equal(Loc.L("Server.Copies.State.Merging", "25"), text);
Assert.Equal(string.Join(Environment.NewLine, Loc.L("Tooltips.Server.Copies.State.Merging"), Loc.L("Server.Copies.State.Progress", "1", "4")), tip);
// The row follows a merge's progress as it follows an Integrate's.
Assert.True(CopyListViewModel.Follows(JobKind.MergeSequences));
Assert.True(CopyListViewModel.Follows(JobKind.Integrate));
Assert.False(CopyListViewModel.Follows(JobKind.UploadCommit));
// A class says what the chosen policy does with it, and a merge says it its own way.
Assert.Equal(Loc.L("Tooltips.Server.Copies.Class.Differs"), CopyText.ClassToolTip(PhotoClass.Differs));
Assert.Equal(Loc.L("Tooltips.Server.Copies.Class.Differs.ThisPcWins"), CopyText.ClassToolTip(PhotoClass.Differs, CopyPhotoPolicy.ThisPcWins));
Assert.Equal(Loc.L("Tooltips.Server.Copies.Class.Differs.KeptWins"), CopyText.ClassToolTip(PhotoClass.Differs, CopyPhotoPolicy.ThisPcWins, isMerge: true));
Assert.Equal(Loc.L("Tooltips.Server.Copies.Class.OnlyHere.Choose"), CopyText.ClassToolTip(PhotoClass.OnlyHere, CopyPhotoPolicy.ChoosePerPhoto));
Assert.Equal(Loc.L("Tooltips.Server.Copies.Class.OnlyThere.Merge"), CopyText.ClassToolTip(PhotoClass.OnlyThere, CopyPhotoPolicy.ChoosePerPhoto, isMerge: true));
Assert.Equal(Loc.L("Tooltips.Server.Copies.Class.SameUnhashed.Integrate"), CopyText.ClassToolTip(PhotoClass.SameUnhashed));
Assert.Equal(Loc.L("Tooltips.Server.Copies.Class.SameUnhashed"), CopyText.ClassToolTip(PhotoClass.SameUnhashed, isMerge: true));
// The class row follows the dialog's policy, and a merge keeping the other sequence reads its classes from the kept side.
var differs = new CopyClassRow(new PhotoClassTotal(PhotoClass.Differs, 2, 51_400_000, 51_800_000));
differs.Policy = CopyPhotoPolicy.OtherWins;
Assert.Equal(Loc.L("Tooltips.Server.Copies.Class.Differs.OtherWins"), differs.ToolTip);
var onlyHere = new CopyClassRow(new PhotoClassTotal(PhotoClass.OnlyHere, 38, 570_000_000, 0), CopyPhotoPolicy.Union, isMerge: true) { Swapped = true };
Assert.Equal(Loc.L("Tooltips.Server.Copies.Class.OnlyThere.Merge"), onlyHere.ToolTip);
// The size cell shows the bytes of the side that holds them; both sides in the tooltip when both do.
var onlyThere = new CopyClassRow(new PhotoClassTotal(PhotoClass.OnlyThere, 3, 0, 45_000_000));
Assert.Equal(Formatting.Bytes(45_000_000), onlyThere.BytesText);
Assert.Equal(Loc.L("Server.Copies.Detail.Server") + " " + Formatting.Bytes(45_000_000), onlyThere.BytesToolTip);
Assert.Equal(Formatting.Bytes(51_400_000), differs.BytesText);
Assert.Equal(string.Join(Loc.Separator, Loc.L("Server.Copies.Detail.ThisPc") + " " + Formatting.Bytes(51_400_000),
Loc.L("Server.Copies.Detail.Server") + " " + Formatting.Bytes(51_800_000)), differs.BytesToolTip);
}
[Test]
public void ASyncRowOfAPairWhoseMatchDeletedPhotosSaysSoAndOffersReview()
{
var entry = Entry(SyncStatus.InSync);
var editor = SyncRights.Of((long)RolePermissions.Default(UserRole.Editor));
foreach (var state in new[] { CopyState.Linked, CopyState.Integrated })
{
var mark = new SyncMark(Copy(state, deletedThere: 3), null);
Assert.Equal((StatusKind.Warning, Loc.L("Server.Copies.State.DeletedThere", "3"), Loc.Plural("Tooltips.Server.Copies.State.DeletedThere", 3)),
SyncText.State(entry, mark));
Assert.SequenceEqual([SyncAction.Compare, SyncAction.Review], SyncText.Actions(entry, editor, mark).TakeLast(2));
Assert.False(string.IsNullOrWhiteSpace(SyncText.ToolTip(entry, SyncAction.Review)));
}
// Nothing deleted: the ordinary sync state, Compare last.
Assert.Equal(SyncText.State(entry), SyncText.State(entry, new SyncMark(Copy(CopyState.Linked), null)));
Assert.Equal(SyncAction.Compare, SyncText.Actions(entry, editor, new SyncMark(Copy(CopyState.Linked), null))[^1]);
}
[Test]
public void TheMatchStatusComesRightAfterTheAnalysisStatus()
{
var analysed = new Chronos.Ui.Visuals.CardStatus(StatusKind.Analysed, "Analysed");
var proxies = new Chronos.Ui.Visuals.CardStatus(StatusKind.Done, "Proxies");
var synced = new Chronos.Ui.Visuals.CardStatus(StatusKind.Synced, "Synced");
var match = new Chronos.Ui.Visuals.CardStatus(StatusKind.Warning, "Also elsewhere");
Assert.SequenceEqual([analysed, match, proxies, synced], Chronos.App.Library.SequenceItem.WithMatch([analysed, proxies, synced], match));
Assert.SequenceEqual([analysed, proxies], Chronos.App.Library.SequenceItem.WithMatch([analysed, proxies], null));
}
[Test]
public void TheMatchWordsNeverUseTheNounCopy()
{
// Design §1.1: the duplicates report owns "copy/copie"; a match is a sequence twice. The photo-level "last copy"
// and the verb "copy" stay.
string[] areas = ["Server.Copies.", "Server.Sync.Skip.", "Server.Sync.State.", "Library.Status.", "Settings.Copy", "Errors.Copies."];
string[] allowed =
[
"Server.Copies.Projects.CopyAcross", "Server.Copies.Plan.LastCopies.one", "Server.Copies.Plan.LastCopies.other",
"Server.Copies.Confirm.LastCopy", "Tooltips.Server.Copies.ToTrashSequence", "Tooltips.Server.Copies.Bring",
];
var noun = new System.Text.RegularExpressions.Regex(@"\b(copy|copie)\b", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
var found = new List<string>();
foreach (var culture in new[] { "en", "it" })
{
foreach (var file in Directory.EnumerateFiles(Path.Combine(TestContext.RepositoryRoot, "i18n", culture), "*.resx"))
{
foreach (var data in System.Xml.Linq.XDocument.Load(file).Root!.Elements("data"))
{
var name = (string)data.Attribute("name")!;
var bare = name.StartsWith("Tooltips.", StringComparison.Ordinal) ? name["Tooltips.".Length..] : name;
if (!areas.Any(a => bare.StartsWith(a, StringComparison.Ordinal)) || allowed.Contains(name)) continue;
if (noun.IsMatch((string?)data.Element("value") ?? string.Empty)) found.Add($"{culture}: {name}");
}
}
}
Assert.Empty(found);
}
[Test]
public void APlanCountsAsSecondVersionsOnlyThoseKeptBesideTheirPair()
{
// Union keeps "a" beside its pair; This PC wins replaces "b" (its loser goes to the trash on the same side).
var steps = new List<PhotoStep>
{
new("a", PhotoAction.SendVersion, Guid.NewGuid(), "IMG_0001.JPG", 10, "a"),
new("b", PhotoAction.SendVersion, Guid.NewGuid(), "IMG_0002.JPG", 10, "b"),
new("b", PhotoAction.TrashThere, Guid.NewGuid(), "IMG_0002.JPG", 10, "b2"),
new("c", PhotoAction.FetchVersion, Guid.NewGuid(), "IMG_0003.JPG", 10, "c"),
new("c", PhotoAction.TrashHere, Guid.NewGuid(), "IMG_0003.JPG", 10, "c2"),
};
Assert.Equal(1, CopyDialogViewModel.KeptVersions(steps, PhotoAction.SendVersion, PhotoAction.TrashThere));
Assert.Equal(0, CopyDialogViewModel.KeptVersions(steps, PhotoAction.FetchVersion, PhotoAction.TrashHere));
}
private static (StatusKind, string) Head((StatusKind Kind, string Text, string ToolTip) state) => (state.Kind, state.Text);
private static FoundCopy Copy(CopyState state, CopyKind kind = CopyKind.LocalServer, int deletedThere = 0, bool gone = false) => new()
@@ -57,6 +57,23 @@ public sealed class UploadHoldTests
Assert.False(UploadHold.Holds(Of(JobKind.MergeSequences)));
}
[Test]
public void AnAutomaticTransferIsHeldOnAMeteredConnectionWithTheOptionOff()
{
// Owner review 6, Q6: new photos of an integrated pair move by themselves, "paused on metered connections".
var automatic = Of(JobKind.Download, $$"""{"server":"{{Server}}","mode":"Originals","automatic":true}""");
var manual = Of(JobKind.Download, $$"""{"server":"{{Server}}","mode":"Originals"}""");
Assert.True(Chronos.Data.Sync.SyncService.IsAutomaticTransfer(automatic));
Assert.False(Chronos.Data.Sync.SyncService.IsAutomaticTransfer(manual));
Assert.True(UploadHold.HeldNow(automatic, metered: true, optionOn: false));
Assert.False(UploadHold.HeldNow(manual, metered: true, optionOn: false));
Assert.True(UploadHold.HeldNow(manual, metered: true, optionOn: true));
Assert.False(UploadHold.HeldNow(automatic, metered: false, optionOn: true));
// An automatic upload too.
Assert.True(UploadHold.HeldNow(Of(JobKind.UploadCommit, $$"""{"server":"{{Server}}","automatic":true}"""), metered: true, optionOn: false));
}
[Test]
public void TransfersWithThisPcsLibraryAndOtherJobsAreNot()
{
@@ -472,6 +472,31 @@ public abstract class SequenceMergerTests(TestContext context) : DatabaseTest(co
Assert.Null(await fx.Db.Sequences.GetAsync(drop.Id));
}
[Test]
public async Task AChangedPhotoOfTheOtherNothingElseHoldsBlocksTheMerge()
{
var fx = await FixtureAsync();
var keep = await SequenceAsync(fx, "keep", [(1, 0, "IMG_0001.JPG")]);
var drop = await SequenceAsync(fx, "drop", [(1, 0, "IMG_0001.JPG"), (2, 10_000, "IMG_0002.JPG")]);
// A photo of the other edited after import: a verify flags it Corrupt (changed), its file holds the only copy.
var edited = (await fx.Db.Frames.ListBySequenceAsync(drop.Id)).First(f => f.Sha256 == Sha(2, 10_000));
var file = fx.Paths.FromRelative(edited.RelativePath);
File.WriteAllBytes(file, Photos.Jpeg(Start.AddMilliseconds(10_000), 88));
await fx.Db.Frames.UpdateFlagsAsync([edited.Id], FrameFlags.Corrupt, FrameFlags.None, Ct);
var copy = await PairAsync(fx, keep.Id, drop.Id);
var merger = Merger(fx);
var choices = await ChoicesAsync(fx, keep.Id, drop.Id, CopyPhotoPolicy.Union);
var plan = await merger.PlanAsync(copy.Id, keep.Id, drop.Id, choices, NoContext, Ct);
Assert.Contains(CopyBlock.DamagedPhotos, plan.Blocks);
Assert.False(plan.CanApply);
Assert.Equal(Chronos.Core.Localization.Loc.L("Errors.Copies.DamagedPhotos", "Drop"), SequenceMerger.BlockText(plan, CopyBlock.DamagedPhotos, "Keep", "Drop"));
// Another sequence of this index holds that content too: nothing would be lost, the merge may go on.
await SequenceAsync(fx, "elsewhere", [(88, 10_000, "IMG_0002.JPG")]);
Assert.DoesNotContain(CopyBlock.DamagedPhotos, (await merger.PlanAsync(copy.Id, keep.Id, drop.Id, choices, NoContext, Ct)).Blocks);
}
[Test]
public async Task APhotoAddedToTheOtherOrDeletedFromTheKeptOneMeanwhileKeepsTheOtherOutOfTheTrash()
{
@@ -353,11 +353,13 @@ public sealed class CopyEngineTests(TestContext context)
];
using var engine = new CopyEngine(f.Sync, f.Archive.Service, new IntegratePlanner(f.Sync, sides, f.Archive.Service.Projects),
new SequenceMerger(f.Db, f.Archive.Service, sides), new CopyReviewBuilder(f.Db, f.Archive.Service.Projects, sides), _ => Context,
workspaceProjects: _ => Task.FromResult(projects));
serverNames: key => key == f.Server ? "Studio NAS" : null, workspaceProjects: _ => Task.FromResult(projects));
var twin = (await engine.TwinsAsync(f.Ct)).Single();
Assert.Equal((pair.Id, linked.Id, "Grade", linkedRemote.Id, "Grade NAS"), (twin.CopyId, twin.LocalId, twin.LocalProject, twin.RemoteId, twin.ServerProject));
Assert.Equal(f.Server, twin.Server);
// The Edit picker shows the server by its name, never by its key.
Assert.Equal("Studio NAS", twin.ServerName);
}
}
@@ -199,6 +199,35 @@ public abstract class FoundCopyStoreTests(TestContext context) : RepositoryTest(
Assert.Count(4, await store.ListAsync(Ct));
}
[Test]
public async Task UploadAgainDeletesTheGoneRowLinkedOrKeptHere()
{
var (db, _, s) = await SetupAsync(2);
var store = new FoundCopyStore(db);
foreach (var (sequence, keptHere) in new[] { (s[0], false), (s[1], true) })
{
var (gone, fresh) = (Guid.CreateVersion7(), Guid.CreateVersion7());
var linked = await store.EnsureLinkedAsync(Nas, gone, sequence.Id, Ct);
// A refresh's 404 forgets the link (hit 1); the recheck counts the second.
await store.MarkRemoteGoneAsync(Nas, gone, sequence.Id, Guid.NewGuid(), TestData.Now, Ct);
await store.MarkRemoteGoneAsync(Nas, gone, sequence.Id, Guid.NewGuid(), TestData.Now.AddHours(1), Ct);
if (keptHere) Assert.True(await store.SetStateAsync(linked.Id, null, CopyState.KeptApart, Answer(), Ct));
Assert.True((await store.GetAsync(linked.Id, Ct))!.RemoteGone);
// Upload again: the first original creates a new server sequence and the link points at it.
var uploaded = await store.EnsureLinkedAsync(Nas, fresh, sequence.Id, Ct);
Assert.Null(await store.GetAsync(linked.Id, Ct));
var left = await store.ListByLocalAsync(sequence.Id, Ct);
Assert.Equal((uploaded.Id, CopyState.Linked, (Guid?)fresh, 0), (left.Single().Id, left.Single().State, left.Single().RemoteId, left.Single().RemoteGoneHits));
// Upload all local no longer reads it as deleted on the server.
var entry = new SyncEntry(sequence, null, SyncStatus.LocalOnly);
var (upload, skipped) = UploadAllRule.Select([entry], left, new HashSet<Guid>(), new HashSet<Guid>());
Assert.Empty(skipped);
Assert.Count(1, upload);
}
}
[Test]
public async Task A404CountsOncePerRefreshAndDeletesTheCandidatesOfThatRemote()
{
@@ -221,6 +221,14 @@ public sealed class IntegrateTests(TestContext context)
plan = await planner.PlanAsync(f.Remote, pair, choices, PlanContext(canUpload: false, canFetch: false), f.Ct);
Assert.Contains(CopyBlock.NoUploadRight, plan.Blocks);
Assert.Contains(CopyBlock.NoFetchRight, plan.Blocks);
// Photos sent into a server sequence the account neither owns nor may edit: the server would refuse them (403).
var readUpload = PlanContext(canDelete: false) with { CanEdit = false, UserId = Guid.NewGuid() };
Assert.Contains(CopyBlock.NoAddRight, (await planner.PlanAsync(f.Remote, pair, choices, readUpload, f.Ct)).Blocks);
Assert.Equal(Loc.L("Errors.Copies.NoAddRight"), IntegratePlanner.BlockText(plan, CopyBlock.NoAddRight, "Comet", "NAS"));
remote.OwnerUserId = readUpload.UserId;
Assert.DoesNotContain(CopyBlock.NoAddRight, (await planner.PlanAsync(f.Remote, pair, choices, readUpload, f.Ct)).Blocks);
Assert.DoesNotContain(CopyBlock.NoAddRight, (await planner.PlanAsync(f.Remote, pair, choices, PlanContext(canDelete: false), f.Ct)).Blocks);
remote.OwnerUserId = null;
// A detail without a side.
plan = await planner.PlanAsync(f.Remote, pair, choices with { Details = new Dictionary<string, CopySide>() }, PlanContext(), f.Ct);
@@ -433,6 +441,26 @@ public sealed class IntegrateTests(TestContext context)
Assert.DoesNotContain(Sha(5, 30_250), await LocalHashesAsync(f, local.Id));
}
[Test]
public async Task AServerSequenceChangedAfterTheWinnerCheckKeepsItsLoser()
{
await using var f = await FixtureAsync(context);
var (engine, _) = Engine(f);
await using var _ = engine;
await engine.StartAsync(f.Ct);
var (local, remote, pair) = await ScenarioAsync(f);
var plan = await Planner(f).PlanAsync(f.Remote, pair, await ChoicesAsync(f, local.Id, remote.Id, CopyPhotoPolicy.ThisPcWins), PlanContext(), f.Ct);
// Another client changes the server sequence after the job read the manifest that showed the winner in place.
f.Remote.OnceBeforeDelete = () => remote.FramesVersion++;
var job = await CopyJobs.EnqueueIntegrateAsync(engine, f.Sync.Copies, plan, local.DisplayTitle, f.Ct);
var failed = await f.Archive.WaitForAsync(job.Id, JobState.Failed);
Assert.Equal(Loc.Plural("Errors.Copies.Kept", 1), failed.Error);
Assert.Empty(f.Remote.Trashed);
Assert.Contains(Sha(5, 30_250), RemoteHashes(remote));
}
[Test]
public async Task AServerRefusalKeepsItsLoserAndTheRestIsDone()
{
@@ -79,6 +79,17 @@ internal sealed class FakeSyncRemote : ISyncRemote
public int CopiedInto { get; private set; }
/// <summary>
/// Uploads into a target refused with 403, as for an account with Read and Upload but not Edit that does not own the
/// target; <see cref="RefusedInto"/> counts them.
/// </summary>
public bool ForbidInto { get; set; }
public int RefusedInto { get; private set; }
/// <summary>Runs once, before the next frame deletion is answered (the server sequence changing meanwhile).</summary>
public Action? OnceBeforeDelete { get; 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; }
@@ -139,6 +150,11 @@ internal sealed class FakeSyncRemote : ISyncRemote
bool capable;
lock (_gate) capable = Capabilities.Contains(ServerCapabilities.UploadInto);
if (!capable) return await UploadFileAsync(path, sequenceId, null, sha256, capturedAt, cancellationToken);
if (ForbidInto)
{
lock (_gate) RefusedInto++;
throw new ChronosApiException(HttpStatusCode.Forbidden, new ApiError("forbidden", "into"));
}
var bytes = await File.ReadAllBytesAsync(path, cancellationToken);
if (Convert.ToHexStringLower(SHA256.HashData(bytes)) != sha256)
throw new ChronosApiException(HttpStatusCode.BadRequest, new ApiError("hash_mismatch", "hash"));
@@ -162,6 +178,11 @@ internal sealed class FakeSyncRemote : ISyncRemote
/// </summary>
public Task<FrameDeleteResultDto> DeleteFramesAsync(Guid sequenceId, FrameDeleteRequest request, CancellationToken cancellationToken)
{
if (OnceBeforeDelete is { } before)
{
OnceBeforeDelete = null;
before();
}
lock (_gate)
{
var sequence = Find(sequenceId);
@@ -492,7 +513,10 @@ internal sealed class FakeSequence
}
public SequenceDto Dto() => new(Id, Title, Title ?? "Untitled", "2026/" + Id.ToString("N"), "Canon", CameraModel, null, FirstCapture, null, Frames.Count, 10,
Frames.Sum(f => (long)f.Bytes.Length), (long)Status, Renders.Count, null, Tags, Rating, Notes, SettingsVersion, FramesVersion, 0, null, UpdatedAt);
Frames.Sum(f => (long)f.Bytes.Length), (long)Status, Renders.Count, null, Tags, Rating, Notes, SettingsVersion, FramesVersion, 0, OwnerUserId, UpdatedAt);
/// <summary>The server account that owns the sequence (none by default).</summary>
public Guid? OwnerUserId { get; set; }
public SequenceManifest Manifest(Func<Guid, bool> proxySent) => new(Id, FramesVersion, SettingsVersion, SettingsJson, Tags,
[.. Frames.Select((f, i) => new ManifestFrame(f.Id, i, f.FileName, f.Bytes.Length, Unhashed ? string.Empty : f.Sha256,
@@ -224,4 +224,25 @@ public sealed class SyncTransferCopyTests(TestContext context)
Assert.True(remote.Frames.Select(fr => fr.Sha256).ToHashSet().SetEquals(photos.Select(Sha)));
Assert.Equal((1, 1), (f.Remote.IntoUploads, f.Remote.CopiedInto));
}
[Test]
public async Task ALinkedUploadTheServerRefusesIntoItsTargetStillFilesEveryOriginal()
{
await using var f = Capable(await SyncFixture.CreateAsync(context));
// An account with Read and Upload but not Edit, whose local sequence is linked to another account's: 403 for "into".
f.Remote.ForbidInto = true;
var photos = f.NewPhotos(4);
var local = await f.LocalAsync("Comet", photos);
var remote = f.Remote.Add("Comet", [photos[0]]);
await f.Sync.LinkAsync(f.Server, remote.Id, local.Id, f.Ct);
var engine = await f.StartEngineAsync();
var job = await f.Sync.EnqueueUploadAsync(engine, f.Server, local);
await f.Archive.WaitForAsync(job.Id, JobState.Done);
// The refusal falls back to the upload as before the server could file into a target: every original is there.
Assert.True(remote.Frames.Select(fr => fr.Sha256).ToHashSet().SetEquals(photos.Select(Sha)));
Assert.True(f.Remote.RefusedInto >= 1);
Assert.Equal(0, f.Remote.IntoUploads);
}
}