fix(settings): an archive row edit reaches the folder it was made for

A retarget now returns the archive registered at its own folder, not at
the folder current when it finishes, so an edit made while folder A opens
no longer lands in the archive of a folder B chosen right after. The rows
and _archive follow only the latest folder; Reset section pushes to the
archive it asked about and reloads the rows when the folder changed. A
newer sidecar met while opening no longer faults the retarget silently:
it is reported like any open failure. The smoke test now waits for the
empty-folder retarget before editing, so the archives[0] fallback would
fail it, and covers the two-folder race.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-12 16:33:45 +00:00
1 parent d2e547f9d2
commit bf2183764f
2 files changed
+69 -18

No files matched your search

@@ -183,11 +183,14 @@ public sealed class SettingsScreenSmokeTests
shell.Navigate(SectionKey.Settings);
settings.Page = SettingsPage.Archive;
// No archive folder: a template edit is this PC's default only, never the first archive of the index.
// No archive folder: a template edit is this PC's default only, never the first archive of the index. The edit is
// made once the rows follow the empty folder, so it cannot wait for anything that would hide a write.
settings.ArchiveRoot.Text = string.Empty;
Assert.True(settings.ArchiveRoot.Commit());
await settings.ArchiveRetarget;
settings.FolderTemplate.Text = "{camera}/{date}";
Assert.True(settings.FolderTemplate.Commit());
Assert.Equal("{camera}/{date}", shell.Services.Settings.FolderTemplate);
// The archive's folder is chosen and a template edited at once, while that archive is still opening: the edit
// reaches its archive.json instead of being undone when it opens, and the row shows it.
@@ -199,6 +202,28 @@ public sealed class SettingsScreenSmokeTests
await WaitAsync(() => settings.FileTemplate.Text == "{date}_{n:0000}" && shell.Services.Settings.FileTemplate == "{date}_{n:0000}", "the row shows it");
Assert.NotEqual("{camera}/{date}", Read(manifestPath).LayoutTemplates.Folder);
// An edit made before a second folder change, while the first folder's archive is still opening, goes to that
// archive: never to the archive at the folder chosen after it.
var otherRoot = System.IO.Path.Combine(shell.Services.Environment.DataDirectory, "other-archive");
await shell.Services.Archives!.CreateAsync(otherRoot, "Other");
var otherManifestPath = new Titano.Core.Archiving.ArchivePaths(otherRoot).ManifestPath;
settings.ArchiveRoot.Text = otherRoot;
Assert.True(settings.ArchiveRoot.Commit());
await settings.ArchiveRetarget;
settings.ArchiveRoot.Text = archive.RootPath;
Assert.True(settings.ArchiveRoot.Commit());
settings.FileTemplate.Text = "{date}-{n:0000}";
Assert.True(settings.FileTemplate.Commit());
settings.ArchiveRoot.Text = otherRoot;
Assert.True(settings.ArchiveRoot.Commit());
await WaitAsync(() => Read(manifestPath).LayoutTemplates.File == "{date}-{n:0000}", "the edit reached the archive of the folder it was made for");
await settings.ArchiveRetarget;
Assert.NotEqual("{date}-{n:0000}", Read(otherManifestPath).LayoutTemplates.File);
Assert.Equal(Read(otherManifestPath).LayoutTemplates.File, settings.FileTemplate.Text);
settings.ArchiveRoot.Text = archive.RootPath;
Assert.True(settings.ArchiveRoot.Commit());
await settings.ArchiveRetarget;
// Offline, only archive.json knows the thumbnail size: this PC's stays instead of becoming the default.
Titano.Core.Archiving.ManifestStore.WriteArchive(manifestPath, Read(manifestPath) with { ThumbnailPolicy = new Titano.Core.Archiving.ThumbnailPolicy { LongEdge = 480 } });
shell.Navigate(SectionKey.Library);