feat(editor): visual crop, rotate/mirror/flip/straighten, colour looks (owner review 1 phase 4) (#26)
CI / Build and test (push) Successful in 8m19s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 12m9s
CI / PostgreSQL 16 integration (push) Successful in 7m49s
CI / PostgreSQL 17 integration (push) Successful in 7m19s
CI / Docker image (push) Successful in 46s
Release / Server image (push) Successful in 1m14s
CI / Build and test (push) Successful in 8m19s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 12m9s
CI / PostgreSQL 16 integration (push) Successful in 7m49s
CI / PostgreSQL 17 integration (push) Successful in 7m19s
CI / Docker image (push) Successful in 46s
Release / Server image (push) Successful in 1m14s
Owner review 1 R5 + R6. Camera rotation, mirror, flip, straighten and crop handles locked to the output; an Exposure Look group; Export output size ("proportions win"); settings format 2 with older-node gates. Also fixes project text and hashes differing between Windows and Linux.
Closes #19
Closes #20
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #26.
This commit is contained in:
1 parent
db389a54f2
commit
188b2c2e55
355 files changed
+10549
-1061
No files matched your search
@@ -167,7 +167,7 @@ internal sealed class WorkspaceRenderJobHandler(ChronosDatabase db, ArchiveServi
|
||||
else if (named is not null) portable = version?.SettingsJson ?? throw new InvalidOperationException(Loc.L("Errors.Workspace.RenderVersion"));
|
||||
else portable = versions.Count > 0 ? versions[^1].SettingsJson : ProjectContent.ToPortable(bundle.Project, media.Photos);
|
||||
// Recorded only for the settings it holds (a version is never named for settings it did not render).
|
||||
Guid? versionId = version is not null && ProjectContent.Verifies(portable, version.ContentHash) ? version.Id : null;
|
||||
Guid? versionId = version is not null && ProjectContent.MatchesHash(portable, version.ContentHash) ? version.Id : null;
|
||||
var settings = portable.Contains("pendingFrames", StringComparison.OrdinalIgnoreCase) ? Place(portable, media.Photos) : portable;
|
||||
var placed = ProjectStore.Parse(settings);
|
||||
var excluded = placed.ExcludedFrames.ToHashSet();
|
||||
|
||||
@@ -217,7 +217,10 @@ internal sealed class WorkspaceSendJobHandler(ChronosDatabase db, ArchiveService
|
||||
if (entry.SettingsHash is { Length: > 0 } hash)
|
||||
{
|
||||
var history = await home.HistoryAsync(projectId, null, ReplayedLookBack, ct).ConfigureAwait(false);
|
||||
same = history.FirstOrDefault(v => string.Equals(v.ContentHash, hash, StringComparison.OrdinalIgnoreCase));
|
||||
// Of the same content whatever its line ends: a version stored by a Windows build before every build wrote LF
|
||||
// holds the CRLF text and its hash.
|
||||
same = history.FirstOrDefault(v => string.Equals(v.ContentHash, hash, StringComparison.OrdinalIgnoreCase)
|
||||
|| (v.SettingsJson is { Length: > 0 } text && ProjectContent.MatchesHash(text, hash)));
|
||||
}
|
||||
if (same is not null)
|
||||
{
|
||||
|
||||
@@ -68,6 +68,12 @@ public sealed record WorkspaceStatus(WorkspaceState State, bool Modified, int Ah
|
||||
|
||||
/// <summary>Version files after the base that cannot be read or do not follow from it (<see cref="WorkspaceState.Damaged"/>).</summary>
|
||||
public int Damaged { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// The highest settings format among the local versions not sent yet (0 when there are none): a home that reads an older
|
||||
/// one (<see cref="IProjectHome.SettingsFormat"/>, an older Chronos Server) is sent none of them (owner review 1, phase 4).
|
||||
/// </summary>
|
||||
public int UnpushedFormat { get; init; }
|
||||
}
|
||||
|
||||
/// <summary>What a push, pull or resolve did: the versions it stored at the home and those it took from there, and where it left the project.</summary>
|
||||
@@ -112,6 +118,12 @@ public sealed record WorkspaceSession(WorkspaceProject Project, ProjectBundle Bu
|
||||
public sealed class WorkspaceSyncException(PushOutcome outcome, string message) : IOException(message)
|
||||
{
|
||||
public PushOutcome Outcome { get; } = outcome;
|
||||
|
||||
/// <summary>
|
||||
/// The home reads an older settings format than a version to send needs (an older Chronos Server; owner review 1, phase
|
||||
/// 4): nothing was sent, the versions wait here until the home is updated.
|
||||
/// </summary>
|
||||
public bool HomeReadsOlderFormat { get; init; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -286,6 +298,7 @@ public sealed class WorkspaceSync(WorkspaceStore store, string clientName)
|
||||
var diverged = false;
|
||||
var locals = Unpushed(project, bundle);
|
||||
EnsureChained(project, bundle, locals);
|
||||
EnsureHomeReads(home, locals, $"project {projectId}");
|
||||
foreach (var local in locals)
|
||||
{
|
||||
var result = await home.PushAsync(projectId, local, cancellationToken).ConfigureAwait(false);
|
||||
@@ -1041,6 +1054,7 @@ public sealed class WorkspaceSync(WorkspaceStore store, string clientName)
|
||||
private async Task<List<ProjectVersion>> SendToCopyAsync(WorkspaceProject project, IProjectHome home, SequenceProject copy, WorkspaceSaveBoth pending,
|
||||
IReadOnlyList<ProjectVersion> locals, CancellationToken cancellationToken)
|
||||
{
|
||||
EnsureHomeReads(home, locals, $"project '{copy.Name}'");
|
||||
var ids = pending.Moves.ToDictionary(m => m.LocalId, m => m.CopyVersionId);
|
||||
var (parentId, parentNumber) = (pending.CopyBaseId, pending.CopyBaseNumber);
|
||||
var pushed = new List<ProjectVersion>(locals.Count);
|
||||
@@ -1085,6 +1099,26 @@ public sealed class WorkspaceSync(WorkspaceStore store, string clientName)
|
||||
/// <summary>The home answered a save-both's copy moved under it (<see cref="PushOutcome.Diverged"/>).</summary>
|
||||
private sealed class CopyMovedException() : Exception("The copy moved at the home.");
|
||||
|
||||
/// <summary>
|
||||
/// Nothing is sent to a home that reads an older settings format than one of <paramref name="locals"/> is written in (an
|
||||
/// older Chronos Server would refuse it, IProjectHome.SettingsFormat): the push stops before the first version, so the
|
||||
/// home never holds half of the chain.
|
||||
/// </summary>
|
||||
/// <exception cref="WorkspaceSyncException"><see cref="WorkspaceSyncException.HomeReadsOlderFormat"/>.</exception>
|
||||
private static void EnsureHomeReads(IProjectHome home, IReadOnlyList<ProjectVersion> locals, string target)
|
||||
{
|
||||
if (FormatOf(locals) is var needed && needed <= home.SettingsFormat) return;
|
||||
throw new WorkspaceSyncException(PushOutcome.NewerFormat,
|
||||
$"The versions of {target} need settings format {needed}, and the home reads {home.SettingsFormat}: nothing was sent (update the server).")
|
||||
{
|
||||
HomeReadsOlderFormat = true,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>The highest settings format of <paramref name="versions"/>; 0 when there are none.</summary>
|
||||
private static int FormatOf(IReadOnlyList<ProjectVersion> versions) =>
|
||||
versions.Count == 0 ? 0 : versions.Max(v => int.Max(v.SettingsFormat, ProjectContent.FormatOf(v.SettingsJson)));
|
||||
|
||||
/// <summary>A push the home refused for good: too large for a version, or refused otherwise (<see cref="WorkspaceSyncException.Outcome"/> says why).</summary>
|
||||
private static WorkspaceSyncException Refused(PushOutcome outcome, ProjectVersion local, string target) => outcome switch
|
||||
{
|
||||
@@ -1099,7 +1133,6 @@ public sealed class WorkspaceSync(WorkspaceStore store, string clientName)
|
||||
var workspace = bundle.Workspace!;
|
||||
var media = project.ReadMedia();
|
||||
var portable = Portable(bundle.Project, media) ?? throw MediaMissing(project.ProjectId);
|
||||
var hash = ProjectContent.Hash(portable);
|
||||
var versions = project.Versions();
|
||||
var locals = Unpushed(versions, bundle);
|
||||
// Saved after a gap, the new version would hang from the versions before it and the ones after it would be left out.
|
||||
@@ -1107,7 +1140,8 @@ public sealed class WorkspaceSync(WorkspaceStore store, string clientName)
|
||||
var (tipId, tipNumber, tipHash) = locals.Count > 0
|
||||
? (locals[^1].Id, locals[^1].Number, locals[^1].ContentHash)
|
||||
: (workspace.Base?.VersionId, workspace.Base?.Number ?? 0, workspace.Base?.ContentHash);
|
||||
if (hash == tipHash || SameAsTip(versions, bundle, locals, portable, media)) return null;
|
||||
// The tip's hash may be of the text with CRLF (saved by a Windows build before every build wrote LF).
|
||||
if (ProjectContent.MatchesHash(portable, tipHash) || SameAsTip(versions, bundle, locals, portable, media)) return null;
|
||||
var sync = project.ReadSync();
|
||||
// A restore taken back since (Undo, Ctrl+Z) no longer shows in the working state: that version is no restore.
|
||||
var restoredFrom = sync.RestoredFrom is { } restored && StillRestores(project, restored, Tip(project, bundle, locals), portable, media?.Photos ?? NoFrames)
|
||||
@@ -1195,7 +1229,7 @@ public sealed class WorkspaceSync(WorkspaceStore store, string clientName)
|
||||
}
|
||||
var tipHash = locals.Count > 0 ? locals[^1].ContentHash : workspace.Base?.ContentHash;
|
||||
var modified = !bundle.IsReadOnly && (Portable(bundle.Project, media) is not { } portable
|
||||
|| (ProjectContent.Hash(portable) != tipHash && !SameAsTip(versions, bundle, locals, portable, media)));
|
||||
|| (!ProjectContent.MatchesHash(portable, tipHash) && !SameAsTip(versions, bundle, locals, portable, media)));
|
||||
var behind = head is not null && head.Id != workspace.Base?.VersionId ? Math.Max(1, head.Number - (workspace.Base?.Number ?? 0)) : 0;
|
||||
// A local commit the home stored although its answer was lost reads as behind by the commits it holds: they are ours.
|
||||
if (head is not null && locals.Any(v => v.Id == head.Id)) behind = 0;
|
||||
@@ -1216,6 +1250,7 @@ public sealed class WorkspaceSync(WorkspaceStore store, string clientName)
|
||||
{
|
||||
MediaOutdated = outdated,
|
||||
Damaged = damaged,
|
||||
UnpushedFormat = FormatOf(locals),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1444,7 +1479,8 @@ public sealed class WorkspaceSync(WorkspaceStore store, string clientName)
|
||||
if (project.Versions().FirstOrDefault(v => v.Id == restoredId) is not { } restored) return true;
|
||||
var then = ProjectContent.Rebind(restored.SettingsJson, photos);
|
||||
var before = parent is null ? ProjectContent.ToPortable(new ProjectSettings(), photos) : ProjectContent.Rebind(parent.SettingsJson, photos);
|
||||
if (then == before) return false;
|
||||
// The same choices are no different, whatever line ends either was stored with (a CRLF version of an older Windows build).
|
||||
if (ProjectContent.SameChoices(then, before, photos)) return false;
|
||||
var now = ProjectContent.Rebind(portable, photos);
|
||||
var merge = ProjectMerge.MergeWithConflicts(ProjectMerge.Read(before), ProjectMerge.Read(now), ProjectMerge.Read(then));
|
||||
return merge.Conflicts.Count == 0 && ProjectContent.Canonical(merge.Merged.ToJson()) == ProjectContent.Canonical(now);
|
||||
|
||||
Reference in new issue
Block a user