mirror of
https://github.com/rmcrackan/Libation.git
synced 2026-09-13 06:07:30 -04:00
Ported from #1949, which surfaces the manual recovery steps the maintainer had been giving out by hand instead of leaving the user with a raw Lucene error. Adapted to the failure now being contained: with the exception no longer escaping into the library change, the scan-failure catch blocks #1949 hooked would never see it, and hooking only those would still miss every other trigger -- removing books is what crashed the GUI. So the guard moves from AppScaffolding into SearchEngineCommands next to the update commands it protects, and raises UpdateFailed from there. Both GUIs subscribe, so any trigger is covered, and the event carries the exception rather than needing #1949's StackTrace string sniffing to find it. The dialog is shown once per session: a damaged index fails on every library change and these steps only need following once. Co-authored-by: rmcrackan <rmcrackan@gmail.com>
34 lines
828 B
C#
34 lines
828 B
C#
using ApplicationServices;
|
|
using LibationUiBase;
|
|
using LibationUiBase.Forms;
|
|
using System;
|
|
|
|
namespace LibationAvalonia.ViewModels;
|
|
|
|
partial class MainVM
|
|
{
|
|
private void Configure_SearchIndex()
|
|
=> SearchEngineCommands.UpdateFailed += searchIndexUpdateFailed;
|
|
|
|
private async void searchIndexUpdateFailed(object? sender, Exception ex)
|
|
{
|
|
try
|
|
{
|
|
if (!SearchIndexRecovery.ShouldNotify())
|
|
return;
|
|
|
|
await MessageBox.Show(
|
|
MainWindow,
|
|
SearchIndexRecovery.ManualRecoveryInstructions,
|
|
SearchIndexRecovery.Caption,
|
|
MessageBoxButtons.OK,
|
|
MessageBoxIcon.Warning);
|
|
}
|
|
catch (Exception dialogEx)
|
|
{
|
|
// nothing above this is allowed to fail: the library change that got us here already succeeded
|
|
Serilog.Log.Logger.Error(dialogEx, "Could not show the search index recovery instructions");
|
|
}
|
|
}
|
|
}
|