fix(workspace): newer-format editor stays usable; media learn the home's photo names
A pull onto a newer Chronos's settings made the editor throw: ProjectHistory.Replace rebased every undo and redo snapshot through ProjectMerge, which refuses to merge a newer format when both sides changed, so any non-empty undo stack broke the reload after a sync that had succeeded. Replace now drops the steps instead when either side (or a step) is of a newer format: the project is shown read-only and undo never brings back values from before the newer settings. The media learnt the home's hashes and conversion aliases only inside a replay, so a status or Save version before that compared a SHA-named base with photo-named media and read a false Modified or saved a version that only re-keyed photos. Now: - ProjectContent.SameChoices also compares the texts as placed on the frames, hashed or not (Bound), so status and commit without a home agree with the base; - a status asked of the home teaches the media its names (written under the lease, or when the lease is free), and so does a checkout of a project already here; - WorkspaceStatus.MediaOutdated reports frames moved at the home, or names the media could not learn yet, and the project menu offers Update media for it (tooltip text updated in en and it). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8256b72913
commit
43b092bd5d
10 files changed
+321
-19
No files matched your search
@@ -118,6 +118,102 @@ public abstract class WorkspaceMergeTests(TestContext context) : DatabaseTest(co
|
||||
Assert.Null(await sync.CommitAsync(id, cancellationToken: fx.Ct));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ABaseNamingAPhotoByItsHashReadsAsTheWorkingStateOnMediaThatHaveNotLearntIt()
|
||||
{
|
||||
var fx = await FixtureAsync();
|
||||
await UnhashAsync(fx, 2);
|
||||
var (_, sync) = fx.Workspace();
|
||||
var project = await fx.CheckoutAsync(sync);
|
||||
var id = project.ProjectId;
|
||||
var copied = project.ReadMedia()!;
|
||||
await EditAsync(sync, id, s => s with { ExcludedFrames = [2] }, fx.Ct);
|
||||
await sync.CommitAsync(id, cancellationToken: fx.Ct);
|
||||
await sync.PushAsync(id, fx.Home, fx.Ct);
|
||||
await VerifyAsync(fx);
|
||||
await WriteAtHomeAsync(fx, s => s with { Exposure = s.Exposure with { ExposureOffsetEv = 0.7 } });
|
||||
Assert.Equal(WorkspaceState.InSync, (await sync.PullAsync(id, fx.Home, fx.Ct)).Status.State);
|
||||
var hashed = (await fx.Db.Frames.ListBySequenceAsync(fx.Sequence.Id))[2].Sha256!;
|
||||
Assert.Contains(hashed, (await fx.Home.HeadAsync(id, fx.Ct)).SettingsJson);
|
||||
|
||||
// Media that have not learnt the hash (copied so, the home out of reach since): the base still holds the working state.
|
||||
project.WriteMedia(copied);
|
||||
var status = await sync.StatusAsync(id, cancellationToken: fx.Ct);
|
||||
Assert.Equal((WorkspaceState.InSync, false), (status.State, status.Modified));
|
||||
Assert.Null(await sync.CommitAsync(id, cancellationToken: fx.Ct));
|
||||
Assert.Empty(sync.Unpushed(id));
|
||||
|
||||
// A change of the user's own still reads as one, and its version keeps the exclusion.
|
||||
await EditAsync(sync, id, s => s with { Exposure = s.Exposure with { ExposureOffsetEv = 0.9 } }, fx.Ct);
|
||||
Assert.True((await sync.StatusAsync(id, cancellationToken: fx.Ct)).Modified);
|
||||
var saved = Assert.NotNull(await sync.CommitAsync(id, cancellationToken: fx.Ct));
|
||||
Assert.SequenceEqual([2], ProjectSettings.FromJson(ProjectContent.Place(saved.SettingsJson, copied.Photos)).ExcludedFrames);
|
||||
Assert.Equal(WorkspaceState.InSync, (await sync.PushAsync(id, fx.Home, fx.Ct)).Status.State);
|
||||
var settings = await SequenceSettingsAsync(fx);
|
||||
Assert.Equal((0.9, 2), (settings.Exposure.ExposureOffsetEv, settings.ExcludedFrames.Single()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task APhotoHashedAtTheHomeIsOutdatedMediaUntilTheMediaLearnItsHash()
|
||||
{
|
||||
var fx = await FixtureAsync();
|
||||
await UnhashAsync(fx, 2);
|
||||
var (_, sync) = fx.Workspace();
|
||||
var project = await fx.CheckoutAsync(sync);
|
||||
var id = project.ProjectId;
|
||||
await EditAsync(sync, id, s => s with { ExcludedFrames = [2] }, fx.Ct);
|
||||
await sync.CommitAsync(id, cancellationToken: fx.Ct);
|
||||
await sync.PushAsync(id, fx.Home, fx.Ct);
|
||||
Assert.False((await sync.StatusAsync(id, fx.Home, fx.Ct)).MediaOutdated);
|
||||
await VerifyAsync(fx);
|
||||
await WriteAtHomeAsync(fx, s => s with { Exposure = s.Exposure with { ExposureOffsetEv = 0.7 } });
|
||||
var hashed = (await fx.Db.Frames.ListBySequenceAsync(fx.Sequence.Id))[2].Sha256!;
|
||||
|
||||
// Asked while another operation holds the project: outdated, the media as they were, nothing to save here.
|
||||
WorkspaceStatus busy;
|
||||
using (await project.LockAsync(TimeSpan.FromSeconds(TestTiming.Budget(10)), fx.Ct))
|
||||
busy = await sync.StatusAsync(id, fx.Home, fx.Ct);
|
||||
Assert.True(busy.MediaOutdated);
|
||||
Assert.Equal((WorkspaceState.Behind, false), (busy.State, busy.Modified));
|
||||
Assert.Null(project.ReadMedia()!.Frames[2].Sha256);
|
||||
Assert.False((await sync.StatusAsync(id, cancellationToken: fx.Ct)).MediaOutdated, "without a home nothing is known of it");
|
||||
|
||||
// Asked again with the project free: the media learn the hash, the frames and their files as copied.
|
||||
var learnt = await sync.StatusAsync(id, fx.Home, fx.Ct);
|
||||
Assert.False(learnt.MediaOutdated);
|
||||
Assert.Equal((WorkspaceState.Behind, false), (learnt.State, learnt.Modified));
|
||||
Assert.Equal(hashed, project.ReadMedia()!.Frames[2].Sha256);
|
||||
var pulled = await sync.PullAsync(id, fx.Home, fx.Ct);
|
||||
Assert.Equal((WorkspaceState.InSync, false), (pulled.Status.State, pulled.Status.MediaOutdated));
|
||||
Assert.SequenceEqual([2], (await sync.OpenAsync(id, fx.Ct)).Working.ExcludedFrames);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task APhotoConvertedAtTheHomeIsOutdatedMediaAndTheMediaLearnItsEncodings()
|
||||
{
|
||||
var fx = await FixtureAsync(4);
|
||||
var (store, sync) = fx.Workspace();
|
||||
var project = await fx.CheckoutAsync(sync);
|
||||
var id = project.ProjectId;
|
||||
var copied = project.ReadMedia()!;
|
||||
Assert.Null(copied.Aliases);
|
||||
await ProjectServiceTests.ConvertAsync(fx.Archive, fx.Sequence.Id, [1], 700);
|
||||
var converted = (await fx.Db.Frames.ListBySequenceAsync(fx.Sequence.Id))[1].Sha256!;
|
||||
|
||||
// Opened again: the media learn the encodings the conversion joined, but still hold the photo as copied.
|
||||
await sync.CheckoutAsync(fx.Home, id, cancellationToken: fx.Ct);
|
||||
var link = Assert.NotNull(project.ReadMedia()!.Aliases).Single();
|
||||
Assert.Equal((copied.Frames[1].Sha256!.ToLowerInvariant(), converted.ToLowerInvariant()), (link.Sha256.ToLowerInvariant(), link.Replacement.ToLowerInvariant()));
|
||||
Assert.Equal(copied.Frames[1].Sha256, project.ReadMedia()!.Frames[1].Sha256);
|
||||
var status = await sync.StatusAsync(id, fx.Home, fx.Ct);
|
||||
Assert.True(status.MediaOutdated, "the file is not the library's any more: Update media copies it again");
|
||||
Assert.False(status.Modified);
|
||||
|
||||
await fx.CopyAsync(store, id);
|
||||
Assert.False((await sync.StatusAsync(id, fx.Home, fx.Ct)).MediaOutdated);
|
||||
Assert.Equal(converted, project.ReadMedia()!.Frames[1].Sha256);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AVersionSavedBeforeAnotherWorkspaceNamedThePhotoByItsHashKeepsItsEdit()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user