merge: desktop settings fixes (V-4, V-6, V-7, V-30, V-31, V-32, V-34, ENG-08)
Merge branch fix2/desktop-settings into the verification branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
34 files changed
+1132
-171
No files matched your search
@@ -114,6 +114,48 @@ public sealed class ArchiveSettingsTests(TestContext context)
|
||||
fx.Service.UpdateSettingsAsync(fx.Archive.Id, s => s with { Proxies = s.Proxies with { LongEdge = 2560 } }, fx.Ct));
|
||||
var shown = await fx.Service.GetSettingsAsync(fx.Archive.Id, fx.Ct);
|
||||
Assert.Equal((1280, FrameImageRenderer.ThumbnailLongEdge), (shown.Proxies.LongEdge, shown.Thumbnails.LongEdge));
|
||||
// A refresh reports that only the index's stand-ins are known: the thumbnail size above is not the archive's.
|
||||
Assert.Null(await fx.Service.RefreshSettingsAsync(fx.Archive.Id, fx.Ct));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ARefreshBringsTheIndexUpToSettingsChangedElsewhere()
|
||||
{
|
||||
await using var fx = await ArchiveFixture.CreateAsync(context);
|
||||
// Another process sharing the archive (a server's admin panel) changed archive.json: this index still has the old row.
|
||||
var manifest = ManifestStore.ReadArchive(fx.Paths.ManifestPath);
|
||||
ManifestStore.WriteArchive(fx.Paths.ManifestPath, manifest with
|
||||
{
|
||||
Name = "Shared",
|
||||
LayoutTemplates = manifest.LayoutTemplates with { Folder = "{year}/{camera}" },
|
||||
ProxyPolicy = manifest.ProxyPolicy with { LongEdge = 2560 },
|
||||
ThumbnailPolicy = manifest.ThumbnailPolicy with { LongEdge = 480 },
|
||||
});
|
||||
Assert.Equal(fx.Archive.FolderTemplate, (await fx.Db.Archives.GetAsync(fx.Archive.Id, fx.Ct))!.FolderTemplate);
|
||||
|
||||
var settings = Assert.NotNull(await fx.Service.RefreshSettingsAsync(fx.Archive.Id, fx.Ct));
|
||||
Assert.Equal(("{year}/{camera}", 2560, 480), (settings.Templates.Folder, settings.Proxies.LongEdge, settings.Thumbnails.LongEdge));
|
||||
var row = (await fx.Db.Archives.GetAsync(fx.Archive.Id, fx.Ct))!;
|
||||
Assert.Equal(("Shared", "{year}/{camera}", 2560), (row.Name, row.FolderTemplate, row.ProxyLongEdge));
|
||||
|
||||
// The drive is unplugged: nothing is known beyond the index, which stays as it is.
|
||||
File.Move(fx.Paths.ManifestPath, fx.Paths.ManifestPath + ".away");
|
||||
Assert.Null(await fx.Service.RefreshSettingsAsync(fx.Archive.Id, fx.Ct));
|
||||
Assert.Equal("{year}/{camera}", (await fx.Db.Archives.GetAsync(fx.Archive.Id, fx.Ct))!.FolderTemplate);
|
||||
|
||||
// A newer Titano rewrote the file: what this one reads of it is neither shown nor registered.
|
||||
ManifestStore.WriteArchive(fx.Paths.ManifestPath, manifest with { Name = "Newer", LayoutTemplates = manifest.LayoutTemplates with { Folder = "{camera}" } });
|
||||
var newer = JsonNode.Parse(await File.ReadAllTextAsync(fx.Paths.ManifestPath, fx.Ct))!;
|
||||
newer["schemaVersion"] = ArchiveManifest.CurrentSchemaVersion + 1;
|
||||
await File.WriteAllTextAsync(fx.Paths.ManifestPath, newer.ToJsonString(), fx.Ct);
|
||||
Assert.Null(await fx.Service.RefreshSettingsAsync(fx.Archive.Id, fx.Ct));
|
||||
var kept = (await fx.Db.Archives.GetAsync(fx.Archive.Id, fx.Ct))!;
|
||||
Assert.Equal(("Shared", "{year}/{camera}"), (kept.Name, kept.FolderTemplate));
|
||||
|
||||
// The folder now holds another archive: its settings are neither shown nor registered as this one's.
|
||||
ManifestStore.WriteArchive(fx.Paths.ManifestPath, manifest with { Id = Guid.CreateVersion7(), Name = "Other" });
|
||||
Assert.Null(await fx.Service.RefreshSettingsAsync(fx.Archive.Id, fx.Ct));
|
||||
Assert.Equal("Shared", (await fx.Db.Archives.GetAsync(fx.Archive.Id, fx.Ct))!.Name);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
Reference in new issue
Block a user