feat: owner review 2 phase 5b: the server as a project home (#17)
CI / Build and test (push) Successful in 9m58s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 6s
Release / Build, test and publish (push) Successful in 14m8s
CI / PostgreSQL 16 integration (push) Successful in 8m55s
CI / PostgreSQL 17 integration (push) Successful in 8m50s
CI / Docker image (push) Successful in 57s
Release / Server image (push) Successful in 1m22s
CI / Build and test (push) Successful in 9m58s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 6s
Release / Build, test and publish (push) Successful in 14m8s
CI / PostgreSQL 16 integration (push) Successful in 8m55s
CI / PostgreSQL 17 integration (push) Successful in 8m50s
CI / Docker image (push) Successful in 57s
Release / Server image (push) Successful in 1m22s
A Chronos Server keeps its sequences' projects, as a PC's archive does: Main and named projects with versions under /api/v1/sequences/{id}/projects, the projects capability and the projectChanged event. The desktop opens a server's sequences in the workspace (proxies downloaded, hash-checked, resumable) with Save version, Sync, conflicts, History, Restore and the project actions against the server. Renders can be of a project version. The admin panel lists a sequence's projects and versions. Strings in all 38 languages.
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 #17.
This commit is contained in:
1 parent
255e149087
commit
81c303f484
325 files changed
+11477
-516
No files matched your search
@@ -177,6 +177,98 @@ public abstract class ProjectRecoveryTests(TestContext context) : DatabaseTest(c
|
||||
Assert.SequenceEqual([0], Settings(fx, sequence).ExcludedFrames);
|
||||
}
|
||||
|
||||
/// <summary>The settings of an index that may hold newer ones than <c>project.json</c>, as the server's does (an earlier release's PATCH wrote the index alone).</summary>
|
||||
private async Task<ArchiveFixture> ServerFixtureAsync() =>
|
||||
Own(await CreateAsync(Context, database: await NewOptionsAsync(multiConnection: true),
|
||||
configure: _ => new ArchiveServiceOptions { Owner = "server", LeaseWait = TimeSpan.FromSeconds(20), IndexSettingsMayLead = true }));
|
||||
|
||||
private static ProjectSettings Exposure(double ev) => new() { Exposure = new ExposureSettings { ExposureOffsetEv = ev } };
|
||||
|
||||
private static double Ev(string json) => ProjectSettings.FromJson(json).Exposure.ExposureOffsetEv;
|
||||
|
||||
[Test]
|
||||
public async Task OnThisPcMainIsBornFromProjectJsonAloneWhenTheIndexDiffers()
|
||||
{
|
||||
var fx = await FixtureAsync();
|
||||
var (sequence, _) = await UploadedAsync(fx, 3);
|
||||
var folder = fx.Paths.Sequence(sequence.Folder);
|
||||
Directory.CreateDirectory(folder.MetaDirectory);
|
||||
File.WriteAllText(folder.ProjectPath, Exposure(0.2).ToJson());
|
||||
await WriteSettingsAsync(fx, sequence.Id, Exposure(0.7));
|
||||
|
||||
// The desktop's every writer writes the file: an index that differs is an old copy, brought up to it.
|
||||
var main = await fx.Service.Projects.MainAsync(sequence.Id, fx.Ct);
|
||||
var history = await fx.Service.Projects.HistoryAsync(main.Id, cancellationToken: fx.Ct);
|
||||
Assert.Equal((1, ProjectVersionKind.Imported), (history.Single().Number, history.Single().Kind));
|
||||
Assert.Equal(0.2, Ev(history.Single().SettingsJson));
|
||||
Assert.Equal(0.2, Ev((await fx.Db.Sequences.GetAsync(sequence.Id))!.SettingsJson!));
|
||||
Assert.Equal(0.2, Settings(fx, sequence).Exposure.ExposureOffsetEv);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task OnAServerMainIsBornWithTheIndexsNewerSettingsInForceAndProjectJsonsKept()
|
||||
{
|
||||
foreach (var readOnly in new[] { false, true })
|
||||
{
|
||||
var fx = await ServerFixtureAsync();
|
||||
var (sequence, _) = await UploadedAsync(fx, 3);
|
||||
var folder = fx.Paths.Sequence(sequence.Folder);
|
||||
Directory.CreateDirectory(folder.MetaDirectory);
|
||||
File.WriteAllText(folder.ProjectPath, Exposure(0.2).ToJson());
|
||||
// A settings PATCH of an earlier release: the index alone.
|
||||
await WriteSettingsAsync(fx, sequence.Id, Exposure(0.7));
|
||||
|
||||
var projects = fx.Service.Projects;
|
||||
if (readOnly)
|
||||
{
|
||||
// On a read-only archive Main is made in the index only, both versions in it, nothing written; its sidecars
|
||||
// and the mirror follow once the archive takes writes.
|
||||
projects.Availability = _ => ArchiveAvailability.ReadOnly;
|
||||
Assert.Equal(2, (await projects.ListAsync(sequence.Id, fx.Ct)).Single().HeadNumber);
|
||||
Assert.False(Directory.Exists(folder.ProjectsDirectory));
|
||||
Assert.Equal(0.2, Settings(fx, sequence).Exposure.ExposureOffsetEv);
|
||||
projects.Availability = ArchiveVolume.Probe;
|
||||
}
|
||||
var main = await projects.MainAsync(sequence.Id, fx.Ct);
|
||||
var history = await projects.HistoryAsync(main.Id, cancellationToken: fx.Ct);
|
||||
Assert.SequenceEqual([(2, ProjectVersionKind.External), (1, ProjectVersionKind.Imported)], history.Select(v => (v.Number, v.Kind)));
|
||||
Assert.Equal((0.7, 0.2), (Ev(history[0].SettingsJson), Ev(history[1].SettingsJson)));
|
||||
Assert.Equal(0.7, Ev((await fx.Db.Sequences.GetAsync(sequence.Id))!.SettingsJson!));
|
||||
Assert.Equal(0.7, Settings(fx, sequence).Exposure.ExposureOffsetEv);
|
||||
// In step now: read again, nothing is added.
|
||||
await projects.ListAsync(sequence.Id, fx.Ct);
|
||||
Assert.Count(2, await projects.HistoryAsync(main.Id, cancellationToken: fx.Ct));
|
||||
Assert.Equal(main.Id, ProjectFolders(folder).Select(d => Guid.ParseExact(Path.GetFileName(d), "N")).Single());
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task OnAServerAnIndexMeetingMainKeepsItsOwnSettingsAsAVersion()
|
||||
{
|
||||
var fx = await ServerFixtureAsync();
|
||||
var (sequence, frames) = await UploadedAsync(fx, 3);
|
||||
var projects = fx.Service.Projects;
|
||||
var main = await projects.MainAsync(sequence.Id, fx.Ct);
|
||||
var pushed = (await projects.PushAsync(main.Id, Draft(await projects.HeadAsync(main.Id, fx.Ct), Exposure(0.4), frames), fx.Ct)).Version!;
|
||||
|
||||
// The index meets Main with no mirror known and its own settings, which no version holds: which is newer cannot be
|
||||
// told, so both are kept, the index's as a version and project.json's (the pushed head) in force on top of it.
|
||||
var row = await WriteSettingsAsync(fx, sequence.Id, Exposure(0.7));
|
||||
await fx.Db.Projects.SetMirroredAsync(main.Id, null, row.SettingsVersion, fx.Ct);
|
||||
var history = await projects.HistoryAsync(main.Id, cancellationToken: fx.Ct);
|
||||
Assert.SequenceEqual([(4, ProjectVersionKind.Restore), (3, ProjectVersionKind.External), (2, ProjectVersionKind.Commit)],
|
||||
history.Take(3).Select(v => (v.Number, v.Kind)));
|
||||
Assert.Equal((0.4, 0.7, pushed.Id), (Ev(history[0].SettingsJson), Ev(history[1].SettingsJson), history[0].RestoredFrom));
|
||||
Assert.Equal(0.4, Ev((await fx.Db.Sequences.GetAsync(sequence.Id))!.SettingsJson!));
|
||||
Assert.Equal(0.4, Settings(fx, sequence).Exposure.ExposureOffsetEv);
|
||||
|
||||
// An index copy a version holds already (a backup's) adds nothing: the head is mirrored.
|
||||
row = await WriteSettingsAsync(fx, sequence.Id, Exposure(0.7));
|
||||
await fx.Db.Projects.SetMirroredAsync(main.Id, null, row.SettingsVersion, fx.Ct);
|
||||
Assert.Count(4, await projects.HistoryAsync(main.Id, cancellationToken: fx.Ct));
|
||||
Assert.Equal(0.4, Ev((await fx.Db.Sequences.GetAsync(sequence.Id))!.SettingsJson!));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AMirrorACrashCutShortBeforeProjectJsonIsCompletedAfterARebuild()
|
||||
{
|
||||
@@ -452,6 +544,32 @@ public abstract class ProjectRecoveryTests(TestContext context) : DatabaseTest(c
|
||||
Assert.SequenceEqual(["Main"], (await projects.ListAsync(sequence.Id, fx.Ct)).Select(p => p.Name));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ARescanTellsTheProjectChangesItFoundOnDisk()
|
||||
{
|
||||
var sets = new System.Collections.Concurrent.ConcurrentQueue<ProjectChangeSet>();
|
||||
var fx = Own(await CreateAsync(Context, database: await NewOptionsAsync(multiConnection: true), configure: o => o with
|
||||
{
|
||||
ProjectsChanged = (set, _) =>
|
||||
{
|
||||
sets.Enqueue(set);
|
||||
return Task.CompletedTask;
|
||||
},
|
||||
}));
|
||||
var (sequence, _) = await UploadedAsync(fx, 2);
|
||||
var vertical = await fx.Service.Projects.CreateAsync(sequence.Id, "Vertical", cancellationToken: fx.Ct);
|
||||
Assert.Contains(sets, s => s.Changes.Any(c => c.ProjectId == vertical.Id && c.Change == Chronos.Protocol.ProjectChanges.Created));
|
||||
|
||||
// Renamed by another PC sharing the archive (its record rewritten): the full rescan reconciles it and says so.
|
||||
sets.Clear();
|
||||
var folder = fx.Paths.Sequence(sequence.Folder);
|
||||
var record = ProjectSidecars.ReadRecord(folder.ProjectRecordPath(vertical.Id));
|
||||
ProjectSidecars.WriteRecord(folder.ProjectRecordPath(vertical.Id), record with { Name = "Square", Updated = record.Updated.AddMinutes(1) });
|
||||
await fx.ScanAsync(ScanMode.Full);
|
||||
Assert.Equal("Square", (await fx.Db.Projects.GetAsync(vertical.Id))!.Name);
|
||||
Assert.Contains(sets, s => s.SequenceId == sequence.Id && s.Changes.Any(c => c.ProjectId == vertical.Id && c.Change == Chronos.Protocol.ProjectChanges.Renamed));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ASequenceOfAReadOnlyArchiveOpensFromItsSidecarsWithoutWriting()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user