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
@@ -1,6 +1,7 @@
|
||||
using Chronos.Core.Archiving;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Core.Project;
|
||||
using Chronos.Data.Archiving;
|
||||
|
||||
namespace Chronos.Data.Projects;
|
||||
|
||||
@@ -78,8 +79,17 @@ public sealed class ArchiveProjectHome(ChronosDatabase db, ProjectService projec
|
||||
return await projects.HeadAsync(projectId, cancellationToken).ConfigureAwait(false);
|
||||
});
|
||||
|
||||
public async Task<ProjectVersion?> GetVersionAsync(Guid projectId, Guid versionId, CancellationToken cancellationToken) =>
|
||||
await projects.GetVersionAsync(versionId, cancellationToken).ConfigureAwait(false) is { } version && version.ProjectId == projectId ? version : null;
|
||||
public Task<ProjectVersion?> GetVersionAsync(Guid projectId, Guid versionId, CancellationToken cancellationToken) =>
|
||||
Reach(async () =>
|
||||
{
|
||||
if (await projects.GetVersionAsync(versionId, cancellationToken).ConfigureAwait(false) is not { } version)
|
||||
{
|
||||
// A version the index does not know yet may be in the sequence's sidecars (see Own): they are read first.
|
||||
await projects.ListAsync(sequenceId, cancellationToken).ConfigureAwait(false);
|
||||
version = await projects.GetVersionAsync(versionId, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
return version is not null && version.ProjectId == projectId ? version : null;
|
||||
});
|
||||
|
||||
public Task<IReadOnlyList<ProjectVersion>> VersionsAfterAsync(Guid projectId, int afterNumber, int limit, CancellationToken cancellationToken) =>
|
||||
Reach(async () =>
|
||||
@@ -104,11 +114,22 @@ public sealed class ArchiveProjectHome(ChronosDatabase db, ProjectService projec
|
||||
|
||||
public Task<HomeFrames> FramesAsync(CancellationToken cancellationToken) => projects.FramesAsync(sequenceId, cancellationToken);
|
||||
|
||||
/// <summary>The project is one of this sequence's.</summary>
|
||||
private async Task<SequenceProject> Own(Guid projectId, CancellationToken cancellationToken) =>
|
||||
await projects.GetAsync(projectId, cancellationToken).ConfigureAwait(false) is { } project && project.SequenceId == sequenceId
|
||||
/// <summary>
|
||||
/// The project is one of this sequence's. One the index does not know yet (an index taken back from an older backup, a
|
||||
/// sequence back from the trash, a project another program sharing the archive made) is looked for in the sequence's
|
||||
/// sidecars first, which every listing brings into the index.
|
||||
/// </summary>
|
||||
private async Task<SequenceProject> Own(Guid projectId, CancellationToken cancellationToken)
|
||||
{
|
||||
if (await projects.GetAsync(projectId, cancellationToken).ConfigureAwait(false) is not { } project)
|
||||
{
|
||||
await projects.ListAsync(sequenceId, cancellationToken).ConfigureAwait(false);
|
||||
project = await projects.GetAsync(projectId, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
return project is not null && project.SequenceId == sequenceId
|
||||
? project
|
||||
: throw new ProjectException(ProjectError.NotFound, $"Project {projectId} is not a project of sequence {sequenceId}.");
|
||||
}
|
||||
|
||||
/// <summary>An archive offline, read-only or busy is a home out of reach for now.</summary>
|
||||
private static async Task<T> Reach<T>(Func<Task<T>> call)
|
||||
@@ -125,5 +146,10 @@ public sealed class ArchiveProjectHome(ChronosDatabase db, ProjectService projec
|
||||
{
|
||||
throw new HomeUnavailableException(ex.Message, ex);
|
||||
}
|
||||
catch (SequenceFolderMovedException ex)
|
||||
{
|
||||
// Another index of the archive moved the sequence: this one finds it at its next scan.
|
||||
throw new HomeUnavailableException(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user