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 apartlinkedintegrating · {0} %
+ merging · {0} %{0} of {1}integrateddeleted 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, replacedlongThe 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 serveryou kept it apart from a matchit came from a server
- the server deleted its copy
+ the server deleted its sequenceit 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 separatecollegatein integrazione · {0} %
+ in unione · {0} %{0} di {1}integrateeliminata 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, sostituitelongLa 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 serverl'hai tenuta separata da una corrispondenzaviene 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 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -257,7 +296,7 @@
-
+
@@ -267,7 +306,7 @@
-
+
diff --git a/src/Chronos.App/Server/Copies/CopyListViewModel.cs b/src/Chronos.App/Server/Copies/CopyListViewModel.cs
index 334f323d..f45a0df3 100644
--- a/src/Chronos.App/Server/Copies/CopyListViewModel.cs
+++ b/src/Chronos.App/Server/Copies/CopyListViewModel.cs
@@ -180,10 +180,10 @@ public sealed class CopyListViewModel : ObservableObject, IDisposable
}
/// Opens the Compare dialog of the pair the sequence is in (Library › Compare…); false when it is in none.
- 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);
});
}
+ /// The jobs a pair's row follows: an Integrate, and a Merge, whose steps come through Progress only (MergeJobHandler).
+ 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();
diff --git a/src/Chronos.App/Server/Copies/CopyPhotoRow.cs b/src/Chronos.App/Server/Copies/CopyPhotoRow.cs
index 8386e69e..95f9b27e 100644
--- a/src/Chronos.App/Server/Copies/CopyPhotoRow.cs
+++ b/src/Chronos.App/Server/Copies/CopyPhotoRow.cs
@@ -9,17 +9,73 @@ using Chronos.Ui.Mvvm;
namespace Chronos.App.Server.Copies;
-/// A line of the Photos part's class table: glyph and class, count, bytes on each side, what it means.
-public sealed class CopyClassRow(PhotoClassTotal total) : ObservableObject
+///
+/// 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.
+///
+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);
+
+ /// The size cell: this side's bytes, or the other side's when this side holds none (Only there, Deleted here).
+ public string BytesText => total.HereBytes > 0 ? HereBytesText : ThereBytesText;
+
+ /// "This PC 51.4 MB · Server 51.8 MB" when both sides hold bytes (Different); otherwise the side the cell shows.
+ 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));
+ }
+ }
+
+ /// The policy the dialog runs with; the tooltip follows it.
+ public CopyPhotoPolicy Policy
+ {
+ get => _policy;
+ set
+ {
+ if (Set(ref _policy, value)) OnPropertyChanged(nameof(ToolTip));
+ }
+ }
+
+ /// A merge keeping the pair's other sequence: this PC's side is the dropped one.
+ 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;
+
+ /// The class seen from the kept sequence (a swapped merge reads Only here as the other's photos).
+ 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");
}
///
diff --git a/src/Chronos.App/Server/Copies/CopyRow.cs b/src/Chronos.App/Server/Copies/CopyRow.cs
index fb97264d..850c6545 100644
--- a/src/Chronos.App/Server/Copies/CopyRow.cs
+++ b/src/Chronos.App/Server/Copies/CopyRow.cs
@@ -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;
diff --git a/src/Chronos.App/Server/Copies/CopyScenes.cs b/src/Chronos.App/Server/Copies/CopyScenes.cs
index b388555d..fee68393 100644
--- a/src/Chronos.App/Server/Copies/CopyScenes.cs
+++ b/src/Chronos.App/Server/Copies/CopyScenes.cs
@@ -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;
}
diff --git a/src/Chronos.App/Server/Copies/CopyText.cs b/src/Chronos.App/Server/Copies/CopyText.cs
index 5fe57811..386b35ae 100644
--- a/src/Chronos.App/Server/Copies/CopyText.cs
+++ b/src/Chronos.App/Server/Copies/CopyText.cs
@@ -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));
+
/// How far an Integrate or Merge job came, in whole per cent ("51"); "0" before it reports.
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);
- /// "Main archive · 1,204 photos": where one side of a pair lies.
- public static string Where(CopyFacts facts, bool isServer) =>
- Loc.Plural(isServer ? "Server.Copies.Where.Server" : "Server.Copies.Where.Archive", facts.Photos, facts.Where);
+ ///
+ /// "Main archive · 1,204 photos": where one side of a pair lies; the server's name alone once it deleted its sequence
+ /// (: no count is known, and "0 photos" would read as an empty sequence).
+ ///
+ 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);
///
/// "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
/// The word of a photo class ("Only here").
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);
+ ///
+ /// What a class means and what the run does with it under : 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.
+ ///
+ 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);
+ }
/// The glyph of a photo class: what an Integrate settles by itself is fine; what waits for a choice is a warning.
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),
diff --git a/src/Chronos.App/Server/SyncRow.cs b/src/Chronos.App/Server/SyncRow.cs
index aba56a72..195314b0 100644
--- a/src/Chronos.App/Server/SyncRow.cs
+++ b/src/Chronos.App/Server/SyncRow.cs
@@ -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
diff --git a/src/Chronos.App/Server/SyncTableViewModel.cs b/src/Chronos.App/Server/SyncTableViewModel.cs
index b06befb0..06efdb8c 100644
--- a/src/Chronos.App/Server/SyncTableViewModel.cs
+++ b/src/Chronos.App/Server/SyncTableViewModel.cs
@@ -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;
diff --git a/src/Chronos.App/Server/SyncText.cs b/src/Chronos.App/Server/SyncText.cs
index 792aec89..9d6d118e 100644
--- a/src/Chronos.App/Server/SyncText.cs
+++ b/src/Chronos.App/Server/SyncText.cs
@@ -46,6 +46,9 @@ public enum SyncAction
/// Compare the row's sequence with its match (owner review 6, #73).
Compare,
+
+ /// Open Compare on the photos the match deleted (design §6.2: "deleted there · n" with Review).
+ Review,
}
///
@@ -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);
}
///
/// 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.
///
public static IReadOnlyList 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;
}
+ /// The photos a linked or integrated match deleted that this side still holds; 0 otherwise.
+ 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;
+
/// The label of a detail line of the Compare dialog ("Deflicker window"); "Other setting" when unknown.
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),
};
diff --git a/src/Chronos.App/Server/UploadHold.cs b/src/Chronos.App/Server/UploadHold.cs
index 9e080f55..4127b8e4 100644
--- a/src/Chronos.App/Server/UploadHold.cs
+++ b/src/Chronos.App/Server/UploadHold.cs
@@ -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 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 (); 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 (); 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; ). 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.
///
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
};
}
+ ///
+ /// Whether is held now: on a metered connection, a job 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").
+ ///
+ 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)
{
diff --git a/src/Chronos.Data/Archiving/SequenceMerger.cs b/src/Chronos.Data/Archiving/SequenceMerger.cs
index 11eb42bd..09e147c1 100644
--- a/src/Chronos.Data/Archiving/SequenceMerger.cs
+++ b/src/Chronos.Data/Archiving/SequenceMerger.cs
@@ -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();
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;
}
+ ///
+ /// 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 () nor any other sequence of this
+ /// index holds; an unreadable such file counts too.
+ ///
+ private async Task DamagedAsync(Guid drop, ArchivePaths dropPaths, IReadOnlySet 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();
+ 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));
+ }
+
///
/// Queues the job that applies : the pair goes to (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),
diff --git a/src/Chronos.Data/Copies/CopyEngine.cs b/src/Chronos.Data/Copies/CopyEngine.cs
index ab2499f7..32a1fa86 100644
--- a/src/Chronos.Data/Copies/CopyEngine.cs
+++ b/src/Chronos.Data/Copies/CopyEngine.cs
@@ -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;
}
diff --git a/src/Chronos.Data/Copies/CopyPlans.cs b/src/Chronos.Data/Copies/CopyPlans.cs
index dbda16a8..1c41764b 100644
--- a/src/Chronos.Data/Copies/CopyPlans.cs
+++ b/src/Chronos.Data/Copies/CopyPlans.cs
@@ -46,6 +46,12 @@ public enum CopyBlock
TrashBlocked,
KeptUnchosen,
ChangedFile,
+
+ /// Photos sent into a server sequence the account neither owns nor may edit (the server refuses that, 403).
+ NoAddRight,
+
+ /// The other sequence of a merge holds photos a verify flagged changed or damaged: they would go to the trash unchecked.
+ DamagedPhotos,
}
/// The choices of an Integrate: photo policy, per-photo choices (by photo key), per-detail sides (by path), projects.
@@ -114,7 +120,11 @@ public sealed record MergePlan(Guid CopyId, Guid KeepId, Guid DropId, MergeChoic
///
public sealed record CopyPlanContext(string PcName, string? ServerName, bool CanUpload, bool CanFetch, bool CanEdit, bool CanDelete,
bool OwnsOrAdmin, bool KeepsProjects, long? QuotaLeft, IReadOnlySet UnsentWorkspaceSequences,
- IReadOnlySet ServerOriginalsArchives);
+ IReadOnlySet ServerOriginalsArchives)
+{
+ /// The signed-in account's id: it owns a server sequence whose owner it is (null: unknown, signed out).
+ public Guid? UserId { get; init; }
+}
/// The server-side dry run of moving photos of a pair's server sequence to the server's trash (design §6.2).
public sealed record TrashTherePlan(Guid CopyId, string Server, Guid RemoteId, IReadOnlyList FrameIds, IReadOnlyList Keys, int Photos,
diff --git a/src/Chronos.Data/Copies/CopyReviewModel.cs b/src/Chronos.Data/Copies/CopyReviewModel.cs
index f98d1970..380af97b 100644
--- a/src/Chronos.Data/Copies/CopyReviewModel.cs
+++ b/src/Chronos.Data/Copies/CopyReviewModel.cs
@@ -38,5 +38,7 @@ public sealed record FoundCopyView(FoundCopy Copy, CopyFacts Here, CopyFacts The
///
/// 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).
///
-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);
diff --git a/src/Chronos.Data/Copies/FoundCopyStore.cs b/src/Chronos.Data/Copies/FoundCopyStore.cs
index 2fb21ce8..57e345e7 100644
--- a/src/Chronos.Data/Copies/FoundCopyStore.cs
+++ b/src/Chronos.Data/Copies/FoundCopyStore.cs
@@ -163,7 +163,8 @@ public sealed class FoundCopyStore(ChronosDatabase db, TimeProvider? time = null
///
/// 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).
///
public Task 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))!;
}
diff --git a/src/Chronos.Data/Copies/IntegrateJobHandler.cs b/src/Chronos.Data/Copies/IntegrateJobHandler.cs
index 9d31359d..6ce1e1c4 100644
--- a/src/Chronos.Data/Copies/IntegrateJobHandler.cs
+++ b/src/Chronos.Data/Copies/IntegrateJobHandler.cs
@@ -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();
}
diff --git a/src/Chronos.Data/Copies/IntegratePlanner.cs b/src/Chronos.Data/Copies/IntegratePlanner.cs
index ac37c72d..75181460 100644
--- a/src/Chronos.Data/Copies/IntegratePlanner.cs
+++ b/src/Chronos.Data/Copies/IntegratePlanner.cs
@@ -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)),
diff --git a/src/Chronos.Data/Sync/SyncService.cs b/src/Chronos.Data/Sync/SyncService.cs
index d3aef0d4..4228044c 100644
--- a/src/Chronos.Data/Sync/SyncService.cs
+++ b/src/Chronos.Data/Sync/SyncService.cs
@@ -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);
+ ///
+ /// Whether is an automatic transfer of an integrated pair's new photos
+ /// (, ): a metered connection pauses
+ /// those whatever the option says (owner review 6, Q6).
+ ///
+ public static bool IsAutomaticTransfer(Job job)
+ {
+ ArgumentNullException.ThrowIfNull(job);
+ return SyncJobParameters.Read(job)?.IsAutomatic == true;
+ }
+
/// Queues sending the renders of a local copy the server lacks (BRIEF §14.5), unless that is already waiting or running.
public Task 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,
diff --git a/src/Chronos.Data/Sync/SyncTransfers.cs b/src/Chronos.Data/Sync/SyncTransfers.cs
index d78fe20b..bb1de8aa 100644
--- a/src/Chronos.Data/Sync/SyncTransfers.cs
+++ b/src/Chronos.Data/Sync/SyncTransfers.cs
@@ -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 ; known by content only now, such an original
/// the server deleted () is not sent back.
///
+ private static Task UploadFrameAsync(JobContext context, ISyncRemote remote, Guid? sequenceId, string? sessionKey, string path,
+ Frame frame, SyncTombstones tombstones, ConcurrentDictionary hashes, CancellationToken cancellationToken, IntoRefusal? into) =>
+ UploadFrameAsync(context, remote, sequenceId, sessionKey, path, frame, tombstones, hashes, cancellationToken, into is not null, into);
+
+ ///
+ /// : through ; with , 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 ().
+ ///
private static async Task UploadFrameAsync(JobContext context, ISyncRemote remote, Guid? sequenceId, string? sessionKey, string path,
- Frame frame, SyncTombstones tombstones, ConcurrentDictionary hashes, CancellationToken cancellationToken, bool into = false)
+ Frame frame, SyncTombstones tombstones, ConcurrentDictionary 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;
}
+ ///
+ /// 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.
+ ///
+ private sealed class IntoRefusal
+ {
+ private int _refused;
+
+ public bool Refused => Volatile.Read(ref _refused) == 1;
+
+ /// Records the refusal; true for the first one.
+ public bool Refuse() => Interlocked.Exchange(ref _refused, 1) == 0;
+ }
+
/// Commits one original from staging into the local sequence (created from the server id when null).
private async Task CommitAsync(Guid remoteId, Guid archiveId, Guid? sequenceId, ManifestFrame frame, string staged, string sha,
IReadOnlyDictionary captured, CancellationToken cancellationToken)
diff --git a/tests/Chronos.App.Tests/Server/CopyScreenSmokeTests.cs b/tests/Chronos.App.Tests/Server/CopyScreenSmokeTests.cs
index 985b2525..79c2e49e 100644
--- a/tests/Chronos.App.Tests/Server/CopyScreenSmokeTests.cs
+++ b/tests/Chronos.App.Tests/Server/CopyScreenSmokeTests.cs
@@ -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();
diff --git a/tests/Chronos.App.Tests/Server/CopyTextTests.cs b/tests/Chronos.App.Tests/Server/CopyTextTests.cs
index d4ca031f..4c586c39 100644
--- a/tests/Chronos.App.Tests/Server/CopyTextTests.cs
+++ b/tests/Chronos.App.Tests/Server/CopyTextTests.cs
@@ -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())
{
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())
+ {
+ 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())
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();
+ 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
+ {
+ 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()
diff --git a/tests/Chronos.App.Tests/Server/UploadHoldTests.cs b/tests/Chronos.App.Tests/Server/UploadHoldTests.cs
index 93236735..758fa786 100644
--- a/tests/Chronos.App.Tests/Server/UploadHoldTests.cs
+++ b/tests/Chronos.App.Tests/Server/UploadHoldTests.cs
@@ -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()
{
diff --git a/tests/Chronos.Data.Tests/Archiving/SequenceMergerTests.cs b/tests/Chronos.Data.Tests/Archiving/SequenceMergerTests.cs
index a7f43231..b46afe27 100644
--- a/tests/Chronos.Data.Tests/Archiving/SequenceMergerTests.cs
+++ b/tests/Chronos.Data.Tests/Archiving/SequenceMergerTests.cs
@@ -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()
{
diff --git a/tests/Chronos.Data.Tests/Copies/CopyEngineTests.cs b/tests/Chronos.Data.Tests/Copies/CopyEngineTests.cs
index 69c95b04..df9ca1ed 100644
--- a/tests/Chronos.Data.Tests/Copies/CopyEngineTests.cs
+++ b/tests/Chronos.Data.Tests/Copies/CopyEngineTests.cs
@@ -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);
}
}
diff --git a/tests/Chronos.Data.Tests/Copies/FoundCopyStoreTests.cs b/tests/Chronos.Data.Tests/Copies/FoundCopyStoreTests.cs
index b4b79b98..bae68976 100644
--- a/tests/Chronos.Data.Tests/Copies/FoundCopyStoreTests.cs
+++ b/tests/Chronos.Data.Tests/Copies/FoundCopyStoreTests.cs
@@ -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(), new HashSet());
+ Assert.Empty(skipped);
+ Assert.Count(1, upload);
+ }
+ }
+
[Test]
public async Task A404CountsOncePerRefreshAndDeletesTheCandidatesOfThatRemote()
{
diff --git a/tests/Chronos.Data.Tests/Copies/IntegrateTests.cs b/tests/Chronos.Data.Tests/Copies/IntegrateTests.cs
index fcc173cf..e1c22541 100644
--- a/tests/Chronos.Data.Tests/Copies/IntegrateTests.cs
+++ b/tests/Chronos.Data.Tests/Copies/IntegrateTests.cs
@@ -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() }, 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()
{
diff --git a/tests/Chronos.Data.Tests/Sync/FakeSyncRemote.cs b/tests/Chronos.Data.Tests/Sync/FakeSyncRemote.cs
index 40210e4c..188f2c30 100644
--- a/tests/Chronos.Data.Tests/Sync/FakeSyncRemote.cs
+++ b/tests/Chronos.Data.Tests/Sync/FakeSyncRemote.cs
@@ -79,6 +79,17 @@ internal sealed class FakeSyncRemote : ISyncRemote
public int CopiedInto { get; private set; }
+ ///
+ /// Uploads into a target refused with 403, as for an account with Read and Upload but not Edit that does not own the
+ /// target; counts them.
+ ///
+ public bool ForbidInto { get; set; }
+
+ public int RefusedInto { get; private set; }
+
+ /// Runs once, before the next frame deletion is answered (the server sequence changing meanwhile).
+ public Action? OnceBeforeDelete { get; set; }
+
/// Frame deletions refused with 403, as for an account that is neither the owner nor an admin.
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
///
public Task 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);
+
+ /// The server account that owns the sequence (none by default).
+ public Guid? OwnerUserId { get; set; }
public SequenceManifest Manifest(Func 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,
diff --git a/tests/Chronos.Data.Tests/Sync/SyncTransferCopyTests.cs b/tests/Chronos.Data.Tests/Sync/SyncTransferCopyTests.cs
index 5038f1b1..843eb2cd 100644
--- a/tests/Chronos.Data.Tests/Sync/SyncTransferCopyTests.cs
+++ b/tests/Chronos.Data.Tests/Sync/SyncTransferCopyTests.cs
@@ -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);
+ }
}