fix(workspace): every cut of a sync is recoverable, renders name only versions the home holds
A push now moves the base before its local file reads as sent; a replay journals itself in sync.json, writes the replayed versions, then the base (the commit point), and only then sets the old ones aside and adopts the local commits the home already held; a conflict met past such commits moves the base onto them first. A save-both journals its copy and the ids it sends under, so a retry completes the same copy instead of making another. The next push, pull or resolve finishes or undoes whatever a cut left, so no version is orphaned and no false conflict appears. The editor reads the working state and the media index under the project lease; workspace.json is written whole and moved into place (an empty one is made again); project files may hold 64 MiB and one that would be larger is refused before it is written, so large projects check out. The workspace copy checks the drive's free space before and during the copy, keeps the folder in its checkpoint and stores a reset when a pass starts again, and runs at High level in the priority queue. Renders record a version only when the index holds it with the settings rendered; an unsent version renders as the project. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
50e28fd63d
commit
833d7cf8e9
18 files changed
+950
-92
No files matched your search
@@ -44,6 +44,23 @@ internal sealed class WorkspaceFixture : IAsyncDisposable
|
||||
return (store, new WorkspaceSync(store, "Chronos on " + name) { LockWait = TimeSpan.FromSeconds(TestTiming.Budget(10)) });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Another sync of <paramref name="store"/> that stops, as a crash would, at the <paramref name="occurrence"/>-th time it
|
||||
/// reaches step <paramref name="step"/> (<see cref="WorkspaceSync.Cut"/>), throwing <see cref="CutException"/>.
|
||||
/// </summary>
|
||||
public static WorkspaceSync Cutting(WorkspaceStore store, string step, int occurrence = 1)
|
||||
{
|
||||
var seen = 0;
|
||||
return new WorkspaceSync(store, "Chronos cut")
|
||||
{
|
||||
LockWait = TimeSpan.FromSeconds(TestTiming.Budget(10)),
|
||||
Cut = name =>
|
||||
{
|
||||
if (name == step && ++seen == occurrence) throw new CutException(step);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>Main of the sequence checked out into <paramref name="sync"/>'s workspace, its media copied.</summary>
|
||||
public async Task<WorkspaceProject> CheckoutAsync(WorkspaceSync sync, Guid? projectId = null)
|
||||
{
|
||||
@@ -81,6 +98,52 @@ internal sealed class WorkspaceFixture : IAsyncDisposable
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A crash between two writes of a sync (<see cref="WorkspaceFixture.Cutting"/>).</summary>
|
||||
internal sealed class CutException(string step) : Exception($"Cut at {step}.");
|
||||
|
||||
/// <summary>
|
||||
/// A home whose pushes can be cut: one refused as out of reach before the home sees it, or one stored whose answer is lost
|
||||
/// on the way back (the program killed, the network dropped).
|
||||
/// </summary>
|
||||
internal sealed class CuttingHome(IProjectHome home) : IProjectHome
|
||||
{
|
||||
public int Pushes { get; private set; }
|
||||
|
||||
/// <summary>The push (counted from 1) refused as out of reach.</summary>
|
||||
public int? Refuse { get; set; }
|
||||
|
||||
/// <summary>The push (counted from 1) the home stores and whose answer is lost.</summary>
|
||||
public int? LoseAnswer { get; set; }
|
||||
|
||||
public async Task<PushResult> PushAsync(Guid projectId, ProjectVersion version, CancellationToken cancellationToken)
|
||||
{
|
||||
var push = ++Pushes;
|
||||
if (push == Refuse) throw new HomeUnavailableException("The home cannot be reached.");
|
||||
var result = await home.PushAsync(projectId, version, cancellationToken);
|
||||
if (push == LoseAnswer) throw new HomeUnavailableException("The answer was lost.");
|
||||
return result;
|
||||
}
|
||||
|
||||
public Task<HomeSequence> SequenceAsync(CancellationToken cancellationToken) => home.SequenceAsync(cancellationToken);
|
||||
public Task<IReadOnlyList<SequenceProject>> ListAsync(CancellationToken cancellationToken) => home.ListAsync(cancellationToken);
|
||||
|
||||
public Task<SequenceProject> CreateAsync(string name, Guid? fromVersionId, string? author, CancellationToken cancellationToken) =>
|
||||
home.CreateAsync(name, fromVersionId, author, cancellationToken);
|
||||
|
||||
public Task<ProjectVersion> HeadAsync(Guid projectId, CancellationToken cancellationToken) => home.HeadAsync(projectId, cancellationToken);
|
||||
|
||||
public Task<ProjectVersion?> GetVersionAsync(Guid projectId, Guid versionId, CancellationToken cancellationToken) =>
|
||||
home.GetVersionAsync(projectId, versionId, cancellationToken);
|
||||
|
||||
public Task<IReadOnlyList<ProjectVersion>> VersionsAfterAsync(Guid projectId, int afterNumber, int limit, CancellationToken cancellationToken) =>
|
||||
home.VersionsAfterAsync(projectId, afterNumber, limit, cancellationToken);
|
||||
|
||||
public Task<IReadOnlyList<ProjectVersion>> HistoryAsync(Guid projectId, int? beforeNumber, int limit, CancellationToken cancellationToken) =>
|
||||
home.HistoryAsync(projectId, beforeNumber, limit, cancellationToken);
|
||||
|
||||
public Task<HomeFrames> FramesAsync(CancellationToken cancellationToken) => home.FramesAsync(cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>A home that cannot be reached, standing for a server out of reach or an archive offline.</summary>
|
||||
internal sealed class UnreachableHome(IProjectHome home) : IProjectHome
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user