feat: wire separate homes into the desktop (owner review 5 P3.2)
The desktop now uses the per-home layout from P3.1: each home keeps its own projects, proxies and originals, and a server is known by its id whichever address reaches it. - Settings keep the known servers (id, name, last address, certificate, aliases, originals archive). Reset and Import keep them; Export leaves them out. - SyncHost records each server the first time it signs in with an id. It names the cache and workspace folders by that id, and re-keys the folders a server had under its addresses at sign-in. The re-key waits while transfer or workspace jobs are pending. - Download originals goes to the server's own archive. It is created beside this PC's archive at the first download, and a toast says where. A sequence that already has a local copy keeps receiving into that copy's archive. A server without an id keeps the 1.0 behaviour. - At start, after the index opens and before any job runs, the folders are sorted into their homes. A toast reports the result: sorted, pending or failed. - The workspace host gives each home's store its own sync. Find, List, usage, clean-up and the trash plan and empty cover every home. Server comparisons go through the identity, so a project stays Online when its server is reached by another address. - The render-node downloads and the server import staging move into the server's folder of the cache. The cache trim keeps `servers`, and the scheduled scan also scans the originals archives. - Settings shows the Home folders rows (Workspace) and the Known servers table (Server). The diagnostics bundle lists the homes. - The dead `AppPaths.CreateDirectories` and `ThumbnailsDirectory` are removed. Refs #66 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4d697a4255
commit
9ad8c6f7a9
44 files changed
+1106
-220
No files matched your search
@@ -43,7 +43,7 @@ public sealed class WorkspaceHostTests(TestContext context)
|
||||
var elsewhere = Path.Combine(context.CreateTempDirectory("fast-disk"), "Chronos workspace");
|
||||
settings.WorkspaceFolder = elsewhere;
|
||||
Assert.Equal(elsewhere, host.Root);
|
||||
Assert.Equal(elsewhere, host.Store.Root, "the store follows the folder");
|
||||
Assert.Equal(elsewhere, host.Homes.Root, "the homes follow the folder");
|
||||
Assert.FileExists(Path.Combine(elsewhere, WorkspaceStore.ManifestFile));
|
||||
|
||||
// A capture (sample data without an engine) edits its library as before.
|
||||
@@ -142,6 +142,60 @@ public sealed class WorkspaceHostTests(TestContext context)
|
||||
Assert.Count(1, imported.WorkspaceOpened);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TheKnownServersStayOnThisPc()
|
||||
{
|
||||
var id = Guid.CreateVersion7();
|
||||
var originals = Guid.CreateVersion7();
|
||||
var mine = new AppSettings
|
||||
{
|
||||
KnownServers = [new KnownServer { Id = id, Name = "Studio NAS", LastAddress = "https://nas.local:8443", Aliases = ["https://nas.local:8443"], OriginalsArchiveId = originals }],
|
||||
};
|
||||
var copy = AppSettings.Parse(mine.ToJson())!;
|
||||
Assert.Equal(("Studio NAS", originals, "https://nas.local:8443"), (copy.KnownServers.Single().Name, copy.KnownServers.Single().OriginalsArchiveId, copy.KnownServers.Single().Aliases.Single()));
|
||||
Assert.Equal(id, copy.FindKnownServer(id)?.Id);
|
||||
Assert.True(copy.KnownIdentity().Same("https://nas.local:8443", Chronos.Core.IO.HomeFolders.IdKey(id)), "an alias names the server by its id");
|
||||
|
||||
// Reset and Import keep what this PC knows of its servers; Export leaves it out.
|
||||
Assert.Equal(id, mine.ResetKeepingState().KnownServers.Single().Id);
|
||||
Assert.Empty(AppSettings.Parse(mine.ForExport().ToJson())!.KnownServers);
|
||||
Assert.Equal(id, mine.KeepLocalIn(AppSettings.Parse(new AppSettings().ToJson())!).KnownServers.Single().Id);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TheTrashOfEveryHomeIsPlannedAndEmptiedTogether()
|
||||
{
|
||||
await using var bed = await WorkspaceTestBed.CreateAsync(context, frames: 2);
|
||||
var host = bed.Host(name: "homes");
|
||||
var homes = host.Homes;
|
||||
Assert.True(homes.IsSplit, "a new workspace is split into homes");
|
||||
var server = homes.StoreFor(new BundleHome(BundleHome.ServerKind, Guid.CreateVersion7(), null, "https://nas.test:8443")).Root;
|
||||
foreach (var (root, name) in new[] { (homes.Local.Root, "a"), (server, "b") })
|
||||
{
|
||||
var entry = Directory.CreateDirectory(Path.Combine(WorkspaceTrash.FolderOf(root), $"{Guid.CreateVersion7():N}-{name}"));
|
||||
File.WriteAllBytes(Path.Combine(entry.FullName, "file.bin"), new byte[100]);
|
||||
}
|
||||
|
||||
// Settings › Workspace › Home folders: this PC first, then the server by what its folder records.
|
||||
var rows = HomeFolderRow.Of(homes, [], _ => { });
|
||||
Assert.SequenceEqual([Loc.L("Settings.Workspace.ThisPc"), "https://nas.test:8443"], rows.Select(r => r.Name).ToArray());
|
||||
Assert.Equal(server, rows[1].Path);
|
||||
|
||||
var usage = await host.UsageAsync(bed.Ct);
|
||||
Assert.Equal((2, 200L), (usage.TrashItems, usage.TrashBytes));
|
||||
var plan = await host.PlanTrashAsync(bed.Ct);
|
||||
Assert.Equal((2, 200L, 2), (plan.Items.Count, plan.Bytes, plan.Listings.Count));
|
||||
|
||||
// One home's trash changed since the plan: nothing is erased, in either.
|
||||
File.WriteAllBytes(Path.Combine(WorkspaceTrash.FolderOf(server), "late.bin"), new byte[5]);
|
||||
await Assert.ThrowsAsync<WorkspaceException>(() => host.EmptyTrashAsync(plan, bed.Ct));
|
||||
Assert.Equal(3, (await host.UsageAsync(bed.Ct)).TrashItems, "nothing was erased");
|
||||
|
||||
var again = await host.PlanTrashAsync(bed.Ct);
|
||||
Assert.Equal(new WorkspaceTrashResult(3, 205), await host.EmptyTrashAsync(again, bed.Ct));
|
||||
Assert.Equal(0, (await host.UsageAsync(bed.Ct)).TrashItems);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OpeningAProjectRecordsWhenAndSavesIt()
|
||||
{
|
||||
@@ -309,7 +363,7 @@ public sealed class WorkspaceHostTests(TestContext context)
|
||||
var verticalId2 = (await host.HomeProjectsAsync(bed.SequenceId)).Single(p => !p.IsMain).Id;
|
||||
await bed.CheckoutAsync(host, verticalId2);
|
||||
Assert.Equal("Vertical", await host.RenameAsync(verticalId2, " Vertical "));
|
||||
Assert.Equal("Vertical", host.Store.Find(verticalId2)!.ReadBundle().Workspace!.Name);
|
||||
Assert.Equal("Vertical", host.Find(verticalId2)!.ReadBundle().Workspace!.Name);
|
||||
Assert.Contains((await host.HomeProjectsAsync(bed.SequenceId)), p => p.Name == "Vertical");
|
||||
|
||||
// Delete project…: confirmed, sent first, then gone from the library's list and from the workspace (kept in the library's trash).
|
||||
@@ -329,7 +383,7 @@ public sealed class WorkspaceHostTests(TestContext context)
|
||||
Assert.Equal(1, deleting.Closed);
|
||||
}
|
||||
Assert.DoesNotContain(verticalId2, (await host.HomeProjectsAsync(bed.SequenceId)).Select(p => p.Id));
|
||||
Assert.Null(host.Store.Find(verticalId2));
|
||||
Assert.Null(host.Find(verticalId2));
|
||||
var row = await bed.RowAsync();
|
||||
var trash = Path.Combine(new Chronos.Core.Archiving.ArchivePaths((await bed.Db.Archives.GetAsync(row.ArchiveId))!.RootPath).Sequence(row.Folder).ProjectsTrashDirectory);
|
||||
Assert.True(Directory.EnumerateDirectories(trash).Any(d => Path.GetFileName(d).StartsWith(verticalId2.ToString("N"), StringComparison.Ordinal)),
|
||||
@@ -375,15 +429,15 @@ public sealed class WorkspaceHostTests(TestContext context)
|
||||
Assert.True(request is { IsDestructive: true, TypedConfirmation: "Main" } && request.TypedPrompt is { Length: > 0 });
|
||||
var refused = await Assert.ThrowsAsync<WorkspaceException>(() => host.RemoveLocalCopyAsync(mainId, discard: false));
|
||||
Assert.Equal(Loc.L("Errors.Workspace.Unsent"), refused.Message);
|
||||
Assert.NotNull(host.Store.Find(mainId), "nothing was removed");
|
||||
Assert.NotNull(host.Find(mainId), "nothing was removed");
|
||||
|
||||
// Send first: saved and sent, then the library's copy is read back and checked before the local one goes.
|
||||
await host.SaveVersionAsync(mainId, "Before removal");
|
||||
await host.SyncAsync(mainId);
|
||||
Assert.True((await host.PlanRemovalAsync(mainId)).IsSafe);
|
||||
var folder = host.Store.Find(mainId)!.Folder;
|
||||
var folder = host.Find(mainId)!.Folder;
|
||||
await host.RemoveLocalCopyAsync(mainId, discard: false);
|
||||
Assert.Null(host.Store.Find(mainId));
|
||||
Assert.Null(host.Find(mainId));
|
||||
Assert.False(Directory.Exists(Path.Combine(folder, WorkspaceProject.MediaFolder)), "the copied photos are gone");
|
||||
Assert.Equal(0.3, ProjectSettings.FromJson((await bed.RowAsync()).SettingsJson!).Exposure.ExposureOffsetEv, "the work is in the library");
|
||||
|
||||
@@ -397,14 +451,14 @@ public sealed class WorkspaceHostTests(TestContext context)
|
||||
}
|
||||
var unsent = (await host.SaveVersionAsync(vertical, "Not sent")).Version!;
|
||||
await host.RemoveLocalCopyAsync(vertical, discard: true);
|
||||
Assert.Null(host.Store.Find(vertical));
|
||||
var aside = Assert.Contains(Directory.EnumerateDirectories(Path.Combine(host.Root, WorkspaceHost.TrashFolder)),
|
||||
Assert.Null(host.Find(vertical));
|
||||
var aside = Assert.Contains(Directory.EnumerateDirectories(Path.Combine(host.Homes.LocalRoot, WorkspaceHost.TrashFolder)),
|
||||
d => Path.GetFileName(d).StartsWith(vertical.ToString("N"), StringComparison.Ordinal));
|
||||
Assert.FileExists(Path.Combine(aside, WorkspaceProject.BundleFile));
|
||||
Assert.True(Directory.EnumerateFiles(Path.Combine(aside, WorkspaceProject.VersionsFolder)).Any(f => f.Contains(unsent.Id.ToString("N"), StringComparison.OrdinalIgnoreCase)
|
||||
|| f.Contains(unsent.Id.ToString(), StringComparison.OrdinalIgnoreCase)), "the version never sent is kept");
|
||||
Assert.False(Directory.Exists(Path.Combine(aside, WorkspaceProject.MediaFolder)), "the photos, copies the library can make again, are not");
|
||||
Assert.Empty(host.Store.List());
|
||||
Assert.Empty(host.Homes.List());
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -413,7 +467,7 @@ public sealed class WorkspaceHostTests(TestContext context)
|
||||
await using var bed = await WorkspaceTestBed.CreateAsync(context, frames: 4);
|
||||
var host = bed.Host(new AppSettings { WorkspaceAutoSync = false });
|
||||
var mainId = await bed.CheckoutAsync(host);
|
||||
var project = host.Store.Find(mainId)!;
|
||||
var project = host.Find(mainId)!;
|
||||
var basis = project.ReadBundle().Workspace!.Base!;
|
||||
var conflict = $$"""
|
||||
"conflict": { "theirsVersionId": "{{basis.VersionId}}", "theirsNumber": {{basis.Number}}, "baseVersionId": "{{Guid.CreateVersion7()}}",
|
||||
@@ -449,9 +503,9 @@ public sealed class WorkspaceHostTests(TestContext context)
|
||||
Assert.True((await host.PlanRemovalAsync(vertical)).Gone);
|
||||
var refused = await Assert.ThrowsAsync<WorkspaceException>(() => host.RemoveLocalCopyAsync(vertical, discard: false));
|
||||
Assert.Equal(Loc.L("Errors.Workspace.DeletedAtHome"), refused.Message);
|
||||
Assert.NotNull(host.Store.Find(vertical), "nothing was removed");
|
||||
Assert.NotNull(host.Find(vertical), "nothing was removed");
|
||||
await host.RemoveLocalCopyAsync(vertical, discard: true);
|
||||
Assert.Null(host.Store.Find(vertical));
|
||||
Assert.Null(host.Find(vertical));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -460,7 +514,7 @@ public sealed class WorkspaceHostTests(TestContext context)
|
||||
await using var bed = await WorkspaceTestBed.CreateAsync(context, frames: 4);
|
||||
var host = bed.Host(new AppSettings { WorkspaceAutoSync = false });
|
||||
var vertical = await bed.CheckoutAsync(host, newName: "Vertical");
|
||||
var project = host.Store.Find(vertical)!;
|
||||
var project = host.Find(vertical)!;
|
||||
var bundle = File.ReadAllBytes(project.BundlePath);
|
||||
var held = Path.Combine(project.Folder, "notes.txt");
|
||||
File.WriteAllText(held, "mine");
|
||||
@@ -471,13 +525,13 @@ public sealed class WorkspaceHostTests(TestContext context)
|
||||
Assert.SequenceEqual(bundle, File.ReadAllBytes(project.BundlePath), "the working state is back");
|
||||
Assert.Contains(await host.ListAsync(), e => e.ProjectId == vertical && e.IsReadable);
|
||||
Assert.True(Directory.Exists(project.MediaDirectory) && Directory.Exists(project.VersionsDirectory), "the copy is whole");
|
||||
var trash = Path.Combine(host.Root, WorkspaceHost.TrashFolder);
|
||||
var trash = Path.Combine(host.Homes.LocalRoot, WorkspaceHost.TrashFolder);
|
||||
Assert.False(Directory.Exists(trash) && Directory.EnumerateDirectories(trash).Any(d => Path.GetFileName(d).StartsWith(vertical.ToString("N"), StringComparison.Ordinal)),
|
||||
"nothing is left aside");
|
||||
|
||||
// The file let go: removed.
|
||||
await host.RemoveLocalCopyAsync(vertical, discard: true);
|
||||
Assert.Null(host.Store.Find(vertical));
|
||||
Assert.Null(host.Find(vertical));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -496,7 +550,7 @@ public sealed class WorkspaceHostTests(TestContext context)
|
||||
await host.SaveVersionAsync(mainId, $"Step {i}");
|
||||
}
|
||||
}
|
||||
var project = host.Store.Find(mainId)!;
|
||||
var project = host.Find(mainId)!;
|
||||
var kept = project.Versions().Where(v => v.StoredAt is not null).Select(v => v.Number).Order().ToList();
|
||||
Assert.SequenceEqual([5, 6], kept, "the base and the one before it");
|
||||
var history = await host.HistoryAsync(mainId);
|
||||
|
||||
Reference in new issue
Block a user