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
@@ -2,10 +2,19 @@ using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using Chronos.Core.IO;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Core.Naming;
|
||||
|
||||
namespace Chronos.Core.Project;
|
||||
|
||||
/// <summary>A project file that would be larger than <see cref="ProjectBundle.MaxBytes"/>: refused before it is written, with a sentence for the user.</summary>
|
||||
public sealed class ProjectTooLargeException(long bytes)
|
||||
: IOException(Loc.L("Errors.Project.TooLarge", ProjectBundle.MaxBytes >> 20))
|
||||
{
|
||||
/// <summary>The size the file would have had.</summary>
|
||||
public long Bytes { get; } = bytes;
|
||||
}
|
||||
|
||||
/// <summary>The archive a project file's sequence lives in: its id, and its name and folder when the file was saved.</summary>
|
||||
public sealed record BundleArchive(Guid Id, string Name, string? Path);
|
||||
|
||||
@@ -70,8 +79,12 @@ public sealed record ProjectBundle(BundleArchive Archive, BundleSequence Sequenc
|
||||
/// <summary>The settings come from a newer Chronos (<see cref="ProjectSettings.IsNewerFormat"/>): show them, never edit them.</summary>
|
||||
public bool IsReadOnly => Project.IsNewerFormat;
|
||||
|
||||
/// <summary>Project settings take a few kilobytes; a larger file is not a project file.</summary>
|
||||
public const int MaxBytes = 4 << 20;
|
||||
/// <summary>
|
||||
/// The largest project file read or written, one limit for both: a workspace's working state parks every position by
|
||||
/// photo until its media are copied (some 260 bytes each), so a 100,000-frame sequence with every frame excluded takes
|
||||
/// some 26 MB; a larger file is not a project file.
|
||||
/// </summary>
|
||||
public const int MaxBytes = 64 << 20;
|
||||
|
||||
private static readonly JsonWriterOptions Indented = new() { Indented = true };
|
||||
|
||||
@@ -165,8 +178,17 @@ public sealed record ProjectBundle(BundleArchive Archive, BundleSequence Sequenc
|
||||
return Parse(reader.ReadToEnd());
|
||||
}
|
||||
|
||||
/// <summary>Writes the file atomically (temp, flush, rename): an interrupted save never leaves half a file.</summary>
|
||||
public void Save(string path) => AtomicFile.WriteAllText(path, ToJson());
|
||||
/// <summary>
|
||||
/// Writes the file atomically (temp, flush, rename): an interrupted save never leaves half a file. A file larger than
|
||||
/// <see cref="MaxBytes"/> is refused before anything is written, as no read could take it back.
|
||||
/// </summary>
|
||||
/// <exception cref="ProjectTooLargeException">The file would be larger than <see cref="MaxBytes"/>.</exception>
|
||||
public void Save(string path)
|
||||
{
|
||||
var bytes = new UTF8Encoding(false).GetBytes(ToJson());
|
||||
if (bytes.Length > MaxBytes) throw new ProjectTooLargeException(bytes.Length);
|
||||
AtomicFile.WriteAllBytes(path, bytes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The settings to give the sequence when the file is opened, the sequence having <paramref name="frameCount"/>
|
||||
|
||||
Reference in new issue
Block a user