fix(workspace): settle conflicts in one answer and give refused folders a way on

Phase 5a fix round 2 of owner review 2 (desktop):

- Take library's no longer commits the working state first, so a take that
  leaves only the library's values sends no empty version; the working state
  it replaces is kept aside in versions/.replaced, outside the chain.
- Conflicts list this side's value as the working state holds it, so one
  answer settles them instead of asking again for the newer value.
- A conflict of format (library saved by a newer Chronos) offers only Save
  both and Later, says why in its tooltip and shows no raw format numbers.
- Conflict lines count the photos a setting differs on ("Excluded frames
  (3)") instead of dropping the duplicates.
- A read-only library is named as such, not as offline; checkouts from it
  stay editable and their versions wait in the workspace.
- A workspace folder refused inside a library offers Choose folder, and
  Settings > Workspace gets Change...: a plan (projects left, projects found)
  is confirmed before the folder changes; nothing is moved.
- Open in workspace shows the copy's size and the drive's free space, and
  warns when the copy would not fit with its 0.5 GB reserve.
- A cancelled first copy removes the half media it wrote.
- A copy whose project.chronos cannot be read is listed as damaged instead of
  hidden, and goes only through Remove local copy > Discard, after a plan.
- Pruning keeps a version whose archive file is damaged (test added).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-03 11:52:49 +01:00
1 parent 8256b72913
commit 64fc5521c0
30 files changed
+1017 -98

No files matched your search

@@ -78,6 +78,80 @@ public abstract class WorkspaceConflictTests(TestContext context) : DatabaseTest
ProjectSettings.FromJson(v.SettingsJson) is { Stack.Mode: StackSetting.StarTrails, Exposure.ExposureOffsetEv: 1.0 }), "the values taken over stay in a version");
}
[Test]
public async Task TakingTheLibrarysValuesOverUnsavedChangesSendsNoVersion()
{
var (fx, _, two, id, shown) = await AskedAsync(await FixtureAsync());
// Unsaved too: a setting only this side changed.
await EditAsync(two, id, s => s with { Motion = s.Motion with { TargetShutterAngle = s.Motion.TargetShutterAngle.WithManual(90) } }, fx.Ct);
var history = await fx.Home.HistoryAsync(id, null, 10, fx.Ct);
var settled = await two.ResolveAsync(id, fx.Home, ConflictChoice.TakeServer, shown: shown, cancellationToken: fx.Ct);
Assert.Null(settled.Status.Conflict);
Assert.Empty(two.Unpushed(id), "no version of the working state is made, so none repeating the head is sent");
Assert.Equal(WorkspaceState.Modified, settled.Status.State, "the change only this side made waits, unsaved as it was");
var working = (await two.OpenAsync(id, fx.Ct)).Working;
Assert.Equal((0.5, StackSetting.Median, 90.0), (working.Exposure.ExposureOffsetEv, working.Stack.Mode, working.Motion.TargetShutterAngle.Resolve(0)));
Assert.Equal(1.0, Assert.NotNull(settled.Kept).Exposure.ExposureOffsetEv);
Assert.Empty((await two.PushAsync(id, fx.Home, fx.Ct)).Pushed);
Assert.Equal(history.Count, (await fx.Home.HistoryAsync(id, null, 10, fx.Ct)).Count, "the library's history holds no empty version");
// The value taken over stays in a version file set aside, outside the versions to send.
var replaced = Path.Combine(two.Store.Find(id)!.VersionsDirectory, WorkspaceProject.ReplacedFolder);
Assert.Contains(Directory.GetFiles(replaced).Select(ProjectSidecars.ReadVersion), v => ProjectSettings.FromJson(v.SettingsJson).Exposure.ExposureOffsetEv == 1.0);
}
[Test]
public async Task AConflictListsTheWorkingStatesValueAndOneAnswerSettlesIt()
{
var fx = await FixtureAsync();
var (_, one) = fx.Workspace("one");
var (_, two) = fx.Workspace("two");
var id = (await fx.CheckoutAsync(one)).ProjectId;
await fx.CheckoutAsync(two, id);
await EditAsync(one, id, s => Offset(s, 0.5), fx.Ct);
await one.CommitAsync(id, cancellationToken: fx.Ct);
await one.PushAsync(id, fx.Home, fx.Ct);
// This side saved 0.8 as a version, then went on to 1 without saving.
await EditAsync(two, id, s => Offset(s, 0.8), fx.Ct);
await two.CommitAsync(id, "warmer", cancellationToken: fx.Ct);
await EditAsync(two, id, s => Offset(s, 1.0), fx.Ct);
var shown = Assert.NotNull((await two.PullAsync(id, fx.Home, fx.Ct)).Status.Conflict);
var difference = shown.Differences.Single();
Assert.Equal(("exposure.exposureOffsetEv", 1.0, 0.5), (difference.Path, Number(difference.Mine), Number(difference.Theirs)),
"this side's value is the one the editor shows");
var settled = await two.ResolveAsync(id, fx.Home, ConflictChoice.TakeServer, shown: shown, cancellationToken: fx.Ct);
Assert.Null(settled.Status.Conflict, "one answer settles what was shown");
Assert.Equal(0.5, (await two.OpenAsync(id, fx.Ct)).Working.Exposure.ExposureOffsetEv);
Assert.Equal(1.0, Assert.NotNull(settled.Kept).Exposure.ExposureOffsetEv);
Assert.Equal("warmer", two.Unpushed(id).Single().Note, "the saved version is replayed, nothing more");
}
[Test]
public async Task KeepMineKeepsTheWorkingStatesValueItListed()
{
var fx = await FixtureAsync();
var (_, one) = fx.Workspace("one");
var (_, two) = fx.Workspace("two");
var id = (await fx.CheckoutAsync(one)).ProjectId;
await fx.CheckoutAsync(two, id);
await EditAsync(one, id, s => Offset(s, 0.5), fx.Ct);
await one.CommitAsync(id, cancellationToken: fx.Ct);
await one.PushAsync(id, fx.Home, fx.Ct);
await EditAsync(two, id, s => Offset(s, 0.8), fx.Ct);
await two.CommitAsync(id, cancellationToken: fx.Ct);
await EditAsync(two, id, s => Offset(s, 1.0), fx.Ct);
var shown = Assert.NotNull((await two.PullAsync(id, fx.Home, fx.Ct)).Status.Conflict);
var settled = await two.ResolveAsync(id, fx.Home, ConflictChoice.KeepMine, shown: shown, cancellationToken: fx.Ct);
Assert.Null(settled.Status.Conflict);
Assert.Equal(1.0, (await two.OpenAsync(id, fx.Ct)).Working.Exposure.ExposureOffsetEv, "the value listed as this side's is kept");
}
private static double? Number(string? json) => json is null ? null : double.Parse(json, System.Globalization.CultureInfo.InvariantCulture);
[Test]
public async Task KeepMineIsAskedAgainWhenTheLibraryMovedOnASettingThisSideChanged()
{
@@ -159,8 +159,8 @@ public abstract class WorkspaceRecoveryTests(TestContext context) : DatabaseTest
Assert.Equal(WorkspaceState.InSync, (await one.PushAsync(id, fx.Home, fx.Ct)).Status.State);
var head = Settings(await fx.Home.HeadAsync(id, fx.Ct));
Assert.Equal((1.0, StackSetting.Mean), (head.Exposure.ExposureOffsetEv, head.Stack.Mode));
// Taking the server's first saves the unsaved offset as a version (kept for its undo); the versions before it reach the home in order.
Assert.SequenceEqual(["first", "other", "second"], (await NotesAsync(fx, id)).Skip(1).Take(3));
// The unsaved offset taken over is kept aside, never sent: the home holds exactly these versions, in order.
Assert.SequenceEqual(["first", "other", "second"], (await NotesAsync(fx, id)).Skip(1));
}
[Test]