fix(app): keep the editor's own save errors and gate an unread archive
- Editor: a failed save showed what the server or the archive layer would say
for the exception's type, so the editor's own sentences were lost: frames
changed on the server or settings changed elsewhere read "The server does not
answer", a read-only account or a gone sequence "Something went wrong". These
failures are now EditorException (an IOException; ProxiesOutdatedException
derives from it) and the toast shows their sentence as it is. A project
written by a newer Titano is reported with the same sentence as a corrupt one
instead of the parser's English text.
- Library: a job posted to a server whose certificate changed since sign-in
threw out of the action unreported; the pin's refusal now reaches the error
toast ("The certificate was not trusted").
- Archive: picking another archive forced it offline until it was read, so the
rebuild dialog called it offline with the previous archive's count, and
disabled commands said the archive must be online. What was read is now kept
apart from availability: until the picked archive is read, Rebuild and the
online commands wait and say so, health fixes and search results of the
previous archive are cleared, and a running search is cancelled.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
15 files changed
+218
-31
No files matched your search
@@ -46,6 +46,10 @@ public sealed class ArchiveViewModel : SectionViewModel
|
||||
private IReadOnlyList<Core.Model.Archive> _archives = [];
|
||||
private Core.Model.Archive? _archive;
|
||||
private ArchiveAvailability _availability = ArchiveAvailability.Offline;
|
||||
|
||||
/// <summary>The archive whose availability, figures and tree were read last: until it is the picked one, nothing acts on them.</summary>
|
||||
private Guid? _readId;
|
||||
|
||||
private ArchiveStats? _stats;
|
||||
private int _withoutProxies;
|
||||
private ArchiveTree? _tree;
|
||||
@@ -79,7 +83,7 @@ public sealed class ArchiveViewModel : SectionViewModel
|
||||
_ = LoadAsync();
|
||||
};
|
||||
ScanCommand = new AsyncRelayCommand(() => QueueAsync(a => ArchiveJobs.Scan(a)), IsOnline);
|
||||
RebuildCommand = new AsyncRelayCommand(() => OpenRebuildDialogAsync(), () => _archive is not null);
|
||||
RebuildCommand = new AsyncRelayCommand(() => OpenRebuildDialogAsync(), IsRead);
|
||||
VerifyCommand = new AsyncRelayCommand(() => QueueAsync(a => ArchiveJobs.Verify(a)), IsOnline);
|
||||
AdoptCommand = new AsyncRelayCommand(AdoptAsync);
|
||||
CopyFolderCommand = new RelayCommand(CopyFolder, () => _archive is not null);
|
||||
@@ -128,11 +132,15 @@ public sealed class ArchiveViewModel : SectionViewModel
|
||||
_orphans = null;
|
||||
if (other)
|
||||
{
|
||||
// Until the picked archive is read, nothing of the previous one stays actionable: no tree to take a set
|
||||
// from, no availability to allow a scan.
|
||||
// Until the picked archive is read (IsRead), nothing of the previous one stays actionable: no tree to take
|
||||
// a set from, no availability to allow a scan, no figures for the rebuild dialog or the health fixes, no
|
||||
// search results. The tooltips say the archive is being read.
|
||||
_search?.Cancel();
|
||||
_tree = null;
|
||||
_availability = ArchiveAvailability.Offline;
|
||||
_stats = null;
|
||||
_health = [];
|
||||
RebuildRows();
|
||||
OnPropertyChanged(string.Empty);
|
||||
CommandManager.InvalidateRequerySuggested();
|
||||
}
|
||||
_ = LoadAsync();
|
||||
@@ -425,6 +433,7 @@ public sealed class ArchiveViewModel : SectionViewModel
|
||||
if (!IsShowing(archive)) return;
|
||||
_availability = availability;
|
||||
_stats = stats;
|
||||
_readId = archive.Id;
|
||||
ShowFigures(stats, withoutProxies);
|
||||
ShowTree(ArchiveTree.Build(archive, availability, sequences));
|
||||
await LoadRecentAsync(db, archive);
|
||||
@@ -444,7 +453,7 @@ public sealed class ArchiveViewModel : SectionViewModel
|
||||
/// <summary>Opens the rebuild dialog (BRIEF §12.5) and counts, off the UI thread, the sidecars the rebuild will read.</summary>
|
||||
public async Task<RebuildDialogViewModel?> OpenRebuildDialogAsync()
|
||||
{
|
||||
if (_archive is not { } archive || Services.Engine is not { } engine) return null;
|
||||
if (_archive is not { } archive || !IsRead() || Services.Engine is not { } engine) return null;
|
||||
var dialog = new RebuildDialogViewModel(archive, _availability, _stats?.Sequences ?? 0, async () =>
|
||||
{
|
||||
var request = ArchiveJobs.Rebuild(archive);
|
||||
@@ -649,13 +658,19 @@ public sealed class ArchiveViewModel : SectionViewModel
|
||||
|
||||
// ---------------- Actions ----------------
|
||||
|
||||
private bool IsOnline() => _archive is not null && _availability == ArchiveAvailability.Online;
|
||||
private bool IsOnline() => IsRead() && _availability == ArchiveAvailability.Online;
|
||||
|
||||
/// <summary>The picked archive's availability and figures are known (a slow volume is probed for seconds).</summary>
|
||||
private bool IsRead() => _archive is { } archive && _readId == archive.Id;
|
||||
|
||||
/// <summary>The archive a read started with is still the one picked.</summary>
|
||||
private bool IsShowing(Core.Model.Archive archive) => _archive?.Id == archive.Id;
|
||||
|
||||
/// <summary>A command's tooltip, or why it is disabled: these commands write to the archive or read all of it.</summary>
|
||||
private string WhenOnline(string key) => _archive is null || IsOnline() ? Loc.L(key) : Loc.L("Archive.Blocked.NotOnline");
|
||||
private string WhenOnline(string key) =>
|
||||
_archive is null || IsOnline() ? Loc.L(key)
|
||||
: !IsRead() ? Loc.L("Archive.Blocked.Reading")
|
||||
: Loc.L("Archive.Blocked.NotOnline");
|
||||
|
||||
private bool HasSet() => _archive is not null && _tree is not null && Set().Count > 0;
|
||||
|
||||
@@ -853,7 +868,10 @@ public sealed class ArchiveViewModel : SectionViewModel
|
||||
try
|
||||
{
|
||||
var groups = await Task.Run(() => archives.FindDuplicatesAsync(archive.Id, search.Token), search.Token);
|
||||
Duplicates = DuplicateRows(groups, await db.Sequences.ListLocationsAsync(archive.Id, search.Token));
|
||||
var locations = await db.Sequences.ListLocationsAsync(archive.Id, search.Token);
|
||||
// Picking another archive cancels the search; one that ended just then is not the picked archive's.
|
||||
if (!IsShowing(archive)) return;
|
||||
Duplicates = DuplicateRows(groups, locations);
|
||||
Log.Info("archive", $"Duplicates search in {archive.RootPath}: {groups.Count} group(s)");
|
||||
}
|
||||
catch (OperationCanceledException) when (search.IsCancellationRequested)
|
||||
@@ -881,7 +899,9 @@ public sealed class ArchiveViewModel : SectionViewModel
|
||||
try
|
||||
{
|
||||
var report = await Task.Run(() => archives.FindOrphansAsync(archive.Id, search.Token), search.Token);
|
||||
Orphans = OrphanRows(report, await db.Sequences.ListLocationsAsync(archive.Id, search.Token));
|
||||
var locations = await db.Sequences.ListLocationsAsync(archive.Id, search.Token);
|
||||
if (!IsShowing(archive)) return;
|
||||
Orphans = OrphanRows(report, locations);
|
||||
Log.Info("archive", $"Orphans search in {archive.RootPath}: {report.UnindexedFiles} unlisted, {report.MissingFiles} missing, "
|
||||
+ $"{report.MissingSequences.Count} rows without sidecar, {report.UnindexedFolders.Count} new folders");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user