fix(archive): an archive picked again is not read until its read ends

Picking archive A, then B, then A again before B's read ended left A's read
marker set while its tree and figures were already cleared: Rebuild, Scan,
Verify and Maintenance were enabled and the rebuild dialog counted 0
sequences. ForgetRead now clears the marker too.

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:21:19 +00:00
1 parent 6e213d4997
commit 78a6f59c42
2 files changed
+11

No files matched your search

@@ -458,6 +458,8 @@ public sealed class ArchiveViewModel : SectionViewModel
/// </summary>
private void ForgetRead()
{
// Picking A, then B, then A again before B's read ends must not find A "read" with none of its figures.
_readId = null;
_search?.Cancel();
_duplicates = null;
_orphans = null;
@@ -184,6 +184,7 @@ public sealed class ArchiveScreenSmokeTests
Assert.Contains(archive.TreeRows, r => r.Node.Kind == TreeNodeKind.Sequence);
Assert.NotEmpty(archive.Tiles);
Assert.NotEmpty(archive.CameraBars);
var first = archive.SelectedArchive!;
var second = await app.Services.Archives!.CreateAsync(Path.Combine(app.Services.Environment.DataDirectory, "second-archive"), "Second");
var reading = archive.LoadAsync();
@@ -205,6 +206,14 @@ public sealed class ArchiveScreenSmokeTests
Assert.False(archive.RebuildCommand.CanExecute(null), "the rebuild dialog waits for the picked archive's own state and figures");
Assert.Null(await archive.OpenRebuildDialogAsync());
Assert.Empty(archive.Health);
// Back to the first archive before the picked one is read: it was read before, but none of its figures is left.
archive.SelectedArchive = first;
Assert.Empty(archive.TreeRows);
Assert.False(archive.RebuildCommand.CanExecute(null), "the first archive is not read again yet");
Assert.False(archive.ScanCommand.CanExecute(null));
Assert.Equal(Loc.L("Archive.Blocked.Reading"), archive.ScanToolTip);
Assert.Null(await archive.OpenRebuildDialogAsync());
archive.SelectedArchive = second;
await reading;
Assert.Equal(second.Id, archive.SelectedArchive!.Id);