diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 9cfc9ca8..8d47bd01 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -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 diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md index 56625390..55ac8797 100644 --- a/docs/DECISIONS.md +++ b/docs/DECISIONS.md @@ -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 | diff --git a/i18n/en/Archive.resx b/i18n/en/Archive.resx index 2be536f2..3fdae8e6 100644 --- a/i18n/en/Archive.resx +++ b/i18n/en/Archive.resx @@ -265,6 +265,7 @@ {0}: changed since it was archived, not uploadedlong: job log line of an upload; {0} file name {0}: deleted on this PC, not downloadedlong: job log line of a download; {0} file name {0}: deleted on the server, not uploadedlong: job log line of an upload; {0} file name + The server refused photos into its sequence; they go as new photos and the server files them by their hashlong: job log line of an upload {0}: its frame here changed meanwhile, not downloadedlong: job log line of a download; {0} file name of the server's copy of a photo this PC holds in another encoding {0}: missing, not uploadedlong: job log line of an upload; {0} file name {0:N0} frame has neither proxy nor thumbnail on the serverlong: job log line of a proxy download diff --git a/i18n/en/Errors.resx b/i18n/en/Errors.resx index 90e7ec92..175d266a 100644 --- a/i18n/en/Errors.resx +++ b/i18n/en/Errors.resx @@ -138,6 +138,7 @@ The details changed on one side meanwhile; the photos are in place, compare again. {0} changed while it was being merged; nothing went to the trash. {0} no longer matches its recorded hash; nothing went to the trash. Run Verify. + Verify found changed or damaged photos in {0} that nothing else holds; repair them before merging. The server deleted its sequence meanwhile; nothing more was sent. {0} photo did not match after copying: nothing went to the trash. {0} photos did not match after copying: nothing went to the trash. @@ -150,6 +151,7 @@ Send or discard the workspace changes of {0} first. Both sequences are linked to {0}: integrate them there first. {0} cannot go to the trash: {1} + This account may not add photos to a server sequence it does not own; ask for the Edit right. Choose {0} detail first. Choose {0} details first. Choose the sequence to keep. diff --git a/i18n/en/Server.resx b/i18n/en/Server.resx index ab3d73ea..9f8d455d 100644 --- a/i18n/en/Server.resx +++ b/i18n/en/Server.resx @@ -312,6 +312,7 @@ kept apart linked integrating · {0} % + merging · {0} % {0} of {1} integrated deleted on server @@ -457,5 +458,7 @@ Type the number of photos of {0} to confirmlong {0:N0} photo exists only in {1}long {0:N0} photos exist only in {1}long + {0:N0} photo of {1} goes to the trash, replacedlong + {0:N0} photos of {1} go to the trash, replacedlong The request asked about too many photos at once.long diff --git a/i18n/en/Tooltips.resx b/i18n/en/Tooltips.resx index 28cb6e53..3d31b2bf 100644 --- a/i18n/en/Tooltips.resx +++ b/i18n/en/Tooltips.resx @@ -1153,10 +1153,10 @@ it may be the same as a sequence on the server you kept it apart from a match it came from a server - the server deleted its copy + the server deleted its sequence it is being integrated - Upload the sequences only here; {0} that may be on the server already is left for review. - Upload the sequences only here; {0} that may be on the server already are left for review. + Upload the sequences only here; {0} is left out (its row says why). + Upload the sequences only here; {0} are left out (each row says why). Look for matches of these sequences on {0} and on this PC now. Look for matches among this PC's archives now. See which photos, details and projects differ between the two sequences. @@ -1181,17 +1181,30 @@ You chose to keep these apart on {0}. Linked: sync compares them; photos move on Upload and Download. Being integrated; the job shows each step. + Being merged; the job shows each step. Photos the other sequence deleted that the kept one holds: they stay in the kept one. New photos move both ways by themselves; deletions wait for you. - The server deleted its copy; this PC's sequence is unchanged. - You kept this PC's sequence after the server deleted its copy. + Some photos were left out: new photos move on Upload and Download. + The server deleted its sequence; this PC's sequence is unchanged. + You kept this PC's sequence after the server deleted its own. {0} photo was deleted on the other side; it stays here until you choose. {0} photos were deleted on the other side; they stay here until you choose. The same files on both sides, by SHA-256. Same size and capture time; one side is not verified yet. A merge checks them by hash first. + Same size and capture time; one side is not verified yet. Integrate counts them as one photo and moves neither. Photos only this side holds; Integrate copies them to the other. + Photos only this side holds; Integrate copies those you tick to the other. + Photos only the kept sequence holds; they stay in it. Photos only the other side holds; Integrate copies them here. + Photos only the other side holds; Integrate copies those you tick here. + Photos only the other sequence holds; Merge copies each into the kept one. Same name and capture time, different files. Union keeps both versions. + Same name and capture time, different files. This PC's file replaces the server's, which goes to the trash. + Same name and capture time, different files. The server's file replaces this PC's, which goes to the trash. + Same name and capture time, different files. The kept sequence's file stays; the other's goes to the trash with it. + Same name and capture time, different files. The other sequence's file replaces the kept one's, which goes to the trash. + Same name and capture time, different files. Choose for each photo; Leave changes nothing. + Same name and capture time, different files. The kept sequence keeps both versions. The same photo in another encoding; counted as one. Deleted on this side, still on the other. Never brought back. Deleted on the other side, still here. Nothing is deleted unless you confirm. @@ -1209,9 +1222,12 @@ Keep both versions of every different photo. What to do with these two different files of one capture time. The value both sequences take. - Take this side's value for every difference. + Take this PC's value for every difference. + Take the value of {0} for every difference. + Take the kept sequence's value for every difference. + Take the other sequence's value for every difference. Each side's other projects appear on the other home with their history, renamed on a clash. - Other projects stay where they are; Edit marks the two workspace copies as twins. + Other projects stay where they are; Edit marks the two workspace projects as twins. A merge always copies the other's projects: its home goes to the trash. Main follows the details you choose. Free space where the photos are filed; the trash frees space only once emptied. @@ -1233,10 +1249,10 @@ Also on {0} · {1} % shared. Also in {0}. Photos of this sequence were deleted on {0}; they stay here until you choose. - {0} deleted its copy of this sequence; this PC's sequence stays until you choose. + {0} deleted its sequence; this PC's sequence stays until you choose. Compare this sequence with its match. Also at {0}: {1}. - What Chronos does with two copies of one sequence it finds. Linked sequences stay in sync. + What Chronos does with the matches it finds (the same sequence twice). Linked sequences stay in sync. Show every match; nothing is linked until you choose. Link sequences with exactly the same photos by themselves; ask for the others. 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. @@ -1247,5 +1263,5 @@ Photos only on one side go to both; for different photos the server's version replaces this PC's, which goes to the trash. Whether an Integrate copies the other projects to the other home, renamed on a clash. Each side's other projects appear on the other home with their history, renamed on a clash. - Other projects stay where they are; Edit marks the two workspace copies as twins. + Other projects stay where they are; Edit marks the two workspace projects as twins. diff --git a/i18n/it/Archive.it.resx b/i18n/it/Archive.it.resx index ba56b7ce..1a2da1ef 100644 --- a/i18n/it/Archive.it.resx +++ b/i18n/it/Archive.it.resx @@ -259,6 +259,7 @@ {0}: cambiato da quando è stato archiviato, non caricato {0}: eliminato su questo PC, non scaricato {0}: eliminato sul server, non caricato + Il server ha rifiutato foto nella sua sequenza; vanno come foto nuove e il server le archivia per hashlong: job log line of an upload {0}: il suo fotogramma qui è cambiato nel frattempo, non scaricato {0}: mancante, non caricato {0:N0} fotogramma non ha né proxy né miniatura sul server diff --git a/i18n/it/Errors.it.resx b/i18n/it/Errors.it.resx index b7559683..276b816f 100644 --- a/i18n/it/Errors.it.resx +++ b/i18n/it/Errors.it.resx @@ -138,6 +138,7 @@ I dettagli sono cambiati su un lato nel frattempo; le foto sono al loro posto, confronta di nuovo. {0} è cambiata durante l'unione; nulla è andato nel cestino. {0} non corrisponde più al suo hash; nulla è andato nel cestino. Esegui Verifica. + Verifica ha trovato foto cambiate o danneggiate in {0} che nient'altro conserva; riparale prima di unire. Il server ha eliminato la sua sequenza nel frattempo; non è stato inviato altro. {0} foto non corrisponde dopo la copia: nulla è andato nel cestino. {0} foto non corrispondono dopo la copia: nulla è andato nel cestino. @@ -150,6 +151,7 @@ Prima invia o scarta le modifiche di lavoro di {0}. Entrambe le sequenze sono collegate a {0}: integrale prima lì. {0} non può andare nel cestino: {1} + Questo account non può aggiungere foto a una sequenza del server non sua; chiedi il permesso Modifica. Prima scegli {0} dettaglio. Prima scegli {0} dettagli. Scegli la sequenza da tenere. diff --git a/i18n/it/Server.it.resx b/i18n/it/Server.it.resx index 4d3251a4..1df934fc 100644 --- a/i18n/it/Server.it.resx +++ b/i18n/it/Server.it.resx @@ -309,6 +309,7 @@ tenute separate collegate in integrazione · {0} % + in unione · {0} % {0} di {1} integrate eliminata sul server @@ -454,5 +455,7 @@ Scrivi il numero di foto di {0} per confermarelong {0:N0} foto esiste solo in {1}long {0:N0} foto esistono solo in {1}long + {0:N0} foto di {1} va nel cestino, sostituitalong + {0:N0} foto di {1} vanno nel cestino, sostituitelong La richiesta chiedeva troppe foto insieme.long diff --git a/i18n/it/Tooltips.it.resx b/i18n/it/Tooltips.it.resx index 658790ce..c9eb90d1 100644 --- a/i18n/it/Tooltips.it.resx +++ b/i18n/it/Tooltips.it.resx @@ -1151,10 +1151,10 @@ potrebbe essere la stessa di una sequenza sul server l'hai tenuta separata da una corrispondenza viene da un server - il server ha eliminato la sua copia + il server ha eliminato la sua sequenza è in integrazione - Carica le sequenze presenti solo qui; {0} che potrebbe essere già sul server resta da rivedere. - Carica le sequenze presenti solo qui; {0} che potrebbero essere già sul server restano da rivedere. + Carica le sequenze presenti solo qui; {0} viene saltata (la sua riga dice perché). + Carica le sequenze presenti solo qui; {0} vengono saltate (ogni riga dice perché). Cerca ora corrispondenze di queste sequenze su {0} e su questo PC. Cerca ora corrispondenze tra gli archivi di questo PC. Mostra quali foto, dettagli e progetti differiscono tra le due sequenze. @@ -1179,17 +1179,30 @@ Hai scelto di tenerle separate il {0}. Collegate: la sincronizzazione le confronta; le foto si spostano con Carica e Scarica. In integrazione; il lavoro mostra ogni passo. + In unione; il lavoro mostra ogni passo. Foto eliminate nell'altra sequenza che quella tenuta conserva: restano in quella tenuta. Le foto nuove passano da sole nei due sensi; le eliminazioni aspettano te. - Il server ha eliminato la sua copia; la sequenza di questo PC è intatta. - Hai tenuto la sequenza di questo PC dopo che il server ha eliminato la sua copia. + Alcune foto sono state escluse: le foto nuove si spostano con Carica e Scarica. + Il server ha eliminato la sua sequenza; quella di questo PC è intatta. + Hai tenuto la sequenza di questo PC dopo che il server ha eliminato la sua. {0} foto è stata eliminata dall'altra parte; resta qui finché non scegli. {0} foto sono state eliminate dall'altra parte; restano qui finché non scegli. Gli stessi file sui due lati, per SHA-256. Stessa dimensione e ora di scatto; un lato non è ancora verificato. Un'unione le controlla prima per hash. + Stessa dimensione e ora di scatto; un lato non è ancora verificato. Integra le conta come una foto e non sposta nessuna delle due. Foto che ha solo questo lato; Integra le copia sull'altro. + Foto che ha solo questo lato; Integra copia sull'altro quelle che spunti. + Foto che ha solo la sequenza tenuta; restano lì. Foto che ha solo l'altro lato; Integra le copia qui. + Foto che ha solo l'altro lato; Integra copia qui quelle che spunti. + Foto che ha solo l'altra sequenza; Unisci le copia tutte in quella tenuta. Stesso nome e ora di scatto, file diversi. Unione tiene entrambe le versioni. + Stesso nome e ora di scatto, file diversi. Il file di questo PC sostituisce quello del server, che va nel cestino. + Stesso nome e ora di scatto, file diversi. Il file del server sostituisce quello di questo PC, che va nel cestino. + Stesso nome e ora di scatto, file diversi. Il file della sequenza tenuta resta; quello dell'altra va nel cestino con lei. + Stesso nome e ora di scatto, file diversi. Il file dell'altra sequenza sostituisce quello della tenuta, che va nel cestino. + Stesso nome e ora di scatto, file diversi. Scegli per ogni foto; Lascia non cambia nulla. + Stesso nome e ora di scatto, file diversi. La sequenza tenuta conserva entrambe le versioni. La stessa foto in un'altra codifica; conta come una. Eliminate da questo lato, ancora sull'altro. Mai riportate. Eliminate dall'altro lato, ancora qui. Nulla si elimina senza conferma. @@ -1207,9 +1220,12 @@ Tiene entrambe le versioni di ogni foto diversa. Cosa fare di questi due file diversi della stessa ora di scatto. Il valore che prendono entrambe le sequenze. - Prende il valore di questo lato per ogni differenza. + Prende il valore di questo PC per ogni differenza. + Prende il valore di {0} per ogni differenza. + Prende il valore della sequenza tenuta per ogni differenza. + Prende il valore dell'altra sequenza per ogni differenza. Gli altri progetti di ogni lato compaiono nell'altra sede con la loro storia, rinominati se il nome è preso. - Gli altri progetti restano dove sono; Modifica segna le due copie di lavoro come gemelle. + Gli altri progetti restano dove sono; Modifica segna i due progetti di lavoro come gemelli. Un'unione copia sempre i progetti dell'altra: la sua sede va nel cestino. Main segue i dettagli che scegli. Spazio libero dove le foto vengono archiviate; il cestino libera spazio solo quando è svuotato. @@ -1231,10 +1247,10 @@ Anche su {0} · {1} % in comune. Anche in {0}. Foto di questa sequenza sono state eliminate su {0}; restano qui finché non scegli. - {0} ha eliminato la sua copia di questa sequenza; quella di questo PC resta finché non scegli. + {0} ha eliminato la sua sequenza; quella di questo PC resta finché non scegli. Confronta questa sequenza con la sua corrispondenza. Anche in {0}: {1}. - Cosa fa Chronos con due copie della stessa sequenza che trova. Le sequenze collegate restano sincronizzate. + Cosa fa Chronos con le corrispondenze che trova (la stessa sequenza due volte). Le sequenze collegate restano sincronizzate. Mostra ogni corrispondenza; nulla si collega finché non scegli. Collega da sole le sequenze con le stesse identiche foto; chiede per le altre. Collega le sequenze che iniziano nello stesso secondo con la stessa fotocamera e condividono almeno metà delle foto, come Chronos 1.1. @@ -1245,5 +1261,5 @@ 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. Se Integra copia gli altri progetti nell'altra sede, rinominati se il nome è preso. Gli altri progetti di ogni lato compaiono nell'altra sede con la loro storia, rinominati se il nome è preso. - Gli altri progetti restano dove sono; Modifica segna le due copie di lavoro come gemelle. + Gli altri progetti restano dove sono; Modifica segna i due progetti di lavoro come gemelli. diff --git a/src/Chronos.App/DesignTime/SampleCopies.cs b/src/Chronos.App/DesignTime/SampleCopies.cs index 22bd9d9e..409cebce 100644 --- a/src/Chronos.App/DesignTime/SampleCopies.cs +++ b/src/Chronos.App/DesignTime/SampleCopies.cs @@ -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 EnqueueMergeAsync(JobEngine engine, MergePlan plan, CancellationToken ct) @@ -152,7 +156,8 @@ internal sealed class SampleCopyEngine : ICopyEngine public Task> TwinsAsync(CancellationToken ct) => Task.FromResult>( [.. _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))]); /// /// 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); } + /// The size of the sample photo at (24.0 to 25.9 MB). + private static long Size(int index) => 24_000_000L + index % 7 * 310_000; + + /// A side's facts; its bytes are the sum of its photos' sizes, so the class table adds up to the header. internal static CopyFacts Facts(Sequence sequence, string where, int photos, bool originals = false, IReadOnlyList? 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) => diff --git a/src/Chronos.App/DesignTime/SampleData.cs b/src/Chronos.App/DesignTime/SampleData.cs index 8bd66e32..f2483d12 100644 --- a/src/Chronos.App/DesignTime/SampleData.cs +++ b/src/Chronos.App/DesignTime/SampleData.cs @@ -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)], diff --git a/src/Chronos.App/Infrastructure/AppServices.cs b/src/Chronos.App/Infrastructure/AppServices.cs index 16fda73b..b305783a 100644 --- a/src/Chronos.App/Infrastructure/AppServices.cs +++ b/src/Chronos.App/Infrastructure/AppServices.cs @@ -254,7 +254,8 @@ public sealed class AppServices : IAsyncDisposable /// /// 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). /// 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(), - originals); + originals) + { + UserId = user?.Id, + }; } /// The name a server key is shown by: the known server's name (by its id), else none (the key is shown). diff --git a/src/Chronos.App/Library/SequenceItem.cs b/src/Chronos.App/Library/SequenceItem.cs index 9141dd0c..aa94eded 100644 --- a/src/Chronos.App/Library/SequenceItem.cs +++ b/src/Chronos.App/Library/SequenceItem.cs @@ -100,8 +100,15 @@ public sealed class SequenceItem : ObservableObject public string TagsText => string.Join(", ", _sequence.Tags); - /// Status glyphs of the card and the list (DESIGN §4: glyph + word, never colour alone). - public IReadOnlyList Statuses => _match is { } match ? [.. BuildStatuses(_sequence, _isAnalysing), match] : BuildStatuses(_sequence, _isAnalysing); + /// + /// 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. + /// + public IReadOnlyList Statuses => WithMatch(BuildStatuses(_sequence, _isAnalysing), _match); + + /// with second (right after the analysis status). + internal static IReadOnlyList WithMatch(IReadOnlyList statuses, CardStatus? match) => match is null ? statuses + : statuses.Count == 0 ? [match] : [statuses[0], match, .. statuses.Skip(1)]; /// /// "Also elsewhere" or "Deleted there" (owner review 6, #73): the sequence is in a pair that asks for a choice; set by the diff --git a/src/Chronos.App/Sections/SequencePickerViewModel.cs b/src/Chronos.App/Sections/SequencePickerViewModel.cs index d6dd5ae6..a3e74fd4 100644 --- a/src/Chronos.App/Sections/SequencePickerViewModel.cs +++ b/src/Chronos.App/Sections/SequencePickerViewModel.cs @@ -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); } diff --git a/src/Chronos.App/Server/Copies/CopyDialogViewModel.cs b/src/Chronos.App/Server/Copies/CopyDialogViewModel.cs index 41fa6497..cea7934e 100644 --- a/src/Chronos.App/Server/Copies/CopyDialogViewModel.cs +++ b/src/Chronos.App/Server/Copies/CopyDialogViewModel.cs @@ -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"); + /// "Take this PC's value for every difference." (a merge: the kept sequence's). + public string AllHereToolTip => Loc.L(IsMerge ? "Tooltips.Server.Copies.Detail.AllKept" : "Tooltips.Server.Copies.Detail.AllHere"); + + /// "Take the server's value for every difference." (a merge: the other sequence's). + public string AllThereToolTip => Loc.L(IsMerge ? "Tooltips.Server.Copies.Detail.AllOther" : "Tooltips.Server.Copies.Detail.AllThere", ServerName); + + /// The Details part's first value column: this PC, or the kept sequence ("Into Old archive"); the pair's first before one is kept. + public string DetailHereHeading => IsMerge && _keepId is null ? Here.Where : HereHeading; + + /// The Details part's second value column: the server, or the other sequence. + public string DetailThereHeading => ThereHeading; + /// A merge keeping the pair's other sequence: the review compares the pair's first with it, so its two columns swap. 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)); } /// A choice changed: the plan follows once the user pauses. @@ -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(); 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 steps, PhotoAction a, PhotoAction b, string key, List 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 steps, PhotoAction a, PhotoAction b, PhotoAction trash, string key, List 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(); } + /// + /// The second versions steps keep beside their pair: a version step whose photo has a + /// step on the same side replaces it instead (This PC wins, Server wins, Other one wins). + /// + internal static int KeptVersions(IReadOnlyList 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)); + } + /// /// "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. /// - internal static ConfirmRequest ReplaceRequest(IntegratePlan plan, string? server = null) + internal ConfirmRequest ReplaceRequest(IntegratePlan plan) => ReplaceRequest(plan, plan.Context?.ServerName ?? ServerName); + + /// + 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 { 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)); diff --git a/src/Chronos.App/Server/Copies/CopyDialogs.xaml b/src/Chronos.App/Server/Copies/CopyDialogs.xaml index 9ad8f063..8bf47d7b 100644 --- a/src/Chronos.App/Server/Copies/CopyDialogs.xaml +++ b/src/Chronos.App/Server/Copies/CopyDialogs.xaml @@ -27,6 +27,18 @@ + + + @@ -73,24 +85,36 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + +