fix: projects and the workspace copy follow phase 4's folder and conversion rules
Phase 5a was written on an early phase 4a state. On top of phase 4b it now keeps the rules every writer of a sequence's folder follows, and keeps project versions intact through Reorganize and conversions: - ProjectService writes project sidecars, project.json and the settings only under the sequence's lease and only in a folder that holds the sequence (SequenceFolders.Holds). A folder another index moved away, or one another sequence was moved into, is refused with SequenceFolderMovedException: reads answer from the index, so no project is taken for gone, nothing is written into the other sequence's folder and the old folder is never created again. The home reports it as out of reach. Full scans and rebuilds reconcile projects the same way, and a failure there is logged instead of failing the scan. - Stored versions park positions by photo and now follow the encodings a Replace conversion (or its undo) joined through the sequence's Replaced tombstones (PhotoAlias, HomePhotos): Main's mirror, renders of a version and workspace media place them on the converted frames. ProjectContent.Rebind/SameChoices name parked photos as the frames hold them now, so a conversion or a hash since is no "external" Main version and no spurious "Modified" in a workspace, and merges see one photo. - The workspace copy job only reads the archive: it no longer runs the archive's proxy pass, makes missing proxies in the workspace, reads only a folder that holds the sequence, starts again when the folder moved or files were renamed during the copy, resumes from a checkpoint of its frames version, and refuses a workspace folder inside any library before it writes anything (Errors.Workspace.InsideLibrary). The working state keeps its positions by frame where frames stay. - ArchiveProjectHome looks for a project or version the index does not know yet in the sequence's sidecars first (an index taken back from a backup, a sequence back from the trash), instead of calling it gone. Tests cover the moved and taken folder, conversions in the archive and in the workspace, the copy refusing a workspace in a library, resuming on other frames, the alias lookup and the rebinding. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b9d1c396a1
commit
50e28fd63d
18 files changed
+596
-91
No files matched your search
@@ -359,13 +359,15 @@ public sealed class WorkspaceSync(WorkspaceStore store, string clientName)
|
||||
locals = [.. locals.Skip(ours.Count)];
|
||||
var media = project.ReadMedia();
|
||||
var photos = media?.Photos ?? NoFrames;
|
||||
var basisSettings = basis is null ? new ProjectSettings() : ProjectMerge.Read(basis.SettingsJson);
|
||||
var headSettings = ProjectMerge.Read(head.SettingsJson);
|
||||
var tip = tipVersion is null ? basisSettings : ProjectMerge.Read(tipVersion.SettingsJson);
|
||||
// Each side names a photo as the frames held it when it was saved: named as the media hold it now (a conversion or a
|
||||
// hash since), the same photo merges as one.
|
||||
var basisSettings = basis is null ? new ProjectSettings() : ProjectMerge.Read(ProjectContent.Rebind(basis.SettingsJson, photos));
|
||||
var headSettings = ProjectMerge.Read(ProjectContent.Rebind(head.SettingsJson, photos));
|
||||
var tip = tipVersion is null ? basisSettings : ProjectMerge.Read(ProjectContent.Rebind(tipVersion.SettingsJson, photos));
|
||||
var working = ProjectMerge.Read(Portable(bundle.Project, media) ?? throw MediaMissing(project.ProjectId));
|
||||
// "Take the server's" everywhere: the paths are those the merge finds, so it runs once to find them.
|
||||
var choice = takeTheirs is EveryPath ? null : takeTheirs;
|
||||
List<ProjectSettings> mine = [.. locals.Select(v => ProjectMerge.Read(v.SettingsJson))];
|
||||
List<ProjectSettings> mine = [.. locals.Select(v => ProjectMerge.Read(ProjectContent.Rebind(v.SettingsJson, photos)))];
|
||||
var replay = ProjectMerge.Replay(basisSettings, mine, headSettings, choice);
|
||||
if (takeTheirs is EveryPath) replay = ProjectMerge.Replay(basisSettings, mine, headSettings, Paths(replay.Conflicts));
|
||||
var newTip = replay.Commits.Count > 0 ? replay.Commits[^1] : headSettings;
|
||||
@@ -469,7 +471,7 @@ 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) return null;
|
||||
if (hash == tipHash || SameAsTip(project, bundle, locals, portable, media)) return null;
|
||||
var sync = project.ReadSync();
|
||||
var version = new ProjectVersion
|
||||
{
|
||||
@@ -509,7 +511,8 @@ public sealed class WorkspaceSync(WorkspaceStore store, string clientName)
|
||||
var conflict = project.ReadSync().Conflict;
|
||||
var locals = Unpushed(project, bundle);
|
||||
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);
|
||||
var modified = !bundle.IsReadOnly && (Portable(bundle.Project, media) is not { } portable
|
||||
|| (ProjectContent.Hash(portable) != tipHash && !SameAsTip(project, bundle, locals, portable, media)));
|
||||
ProjectVersion? head = null;
|
||||
var offline = false;
|
||||
if (home is not null)
|
||||
@@ -536,6 +539,18 @@ public sealed class WorkspaceSync(WorkspaceStore store, string clientName)
|
||||
return new WorkspaceStatus(state, modified, locals.Count, behind, offline, media is null, bundle.IsReadOnly, conflict, workspace.Base, head);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the working state's portable form holds what the last version does (the last local one, else the base),
|
||||
/// once each names its photos as the media hold them now: a version saved before the media were copied again after a
|
||||
/// conversion or a hash at the home parks the same photos under their former names.
|
||||
/// </summary>
|
||||
private static bool SameAsTip(WorkspaceProject project, ProjectBundle bundle, List<ProjectVersion> locals, string portable, WorkspaceMedia? media)
|
||||
{
|
||||
if (media is null) return false;
|
||||
var tip = locals.Count > 0 ? locals[^1] : bundle.Workspace!.Base is { } basis ? project.Versions().FirstOrDefault(v => v.Id == basis.VersionId) : null;
|
||||
return tip is not null && ProjectContent.SameChoices(tip.SettingsJson, portable, media.Photos);
|
||||
}
|
||||
|
||||
/// <summary>The local versions after the base, oldest first, each the child of the one before (the base's for the first).</summary>
|
||||
private static List<ProjectVersion> Unpushed(WorkspaceProject project, ProjectBundle bundle)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user