Finish an interrupted rebuild and replay the past without acting on it

The independent review found that a rebuild cut halfway was never finished
(stops canceled or lowered), that old stop executions replayed from the broker
queued a real sale, that a pending "close all" survived the restore, and that
reconciliation and corporate actions touched accounts not rebuilt yet. The
rebuild now keeps its starting point until it ends, protects the bot before the
first row, meets the splits at their date and leaves the ledger alone until it
is done. Dividends count the shares of after a split. A failed restore of a
missing SQLite file leaves no empty database, and a failed migration can be
tried again from the choice page.

refs #69 #75

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-12-01 22:15:34 +01:00
1 parent 24e20584d4
commit 5ef54b6f2a
17 files changed
+613 -80

No files matched your search

+13
View File
@@ -1168,6 +1168,7 @@ internal static partial class Forms
}
var verdict = status.Identity.Verdict;
var done = false;
try
{
switch (choice)
@@ -1197,19 +1198,31 @@ internal static partial class Forms
break;
case "usa-questo" when verdict is IdentityVerdict.DifferentInstallation or IdentityVerdict.StaleDatabase or IdentityVerdict.MissingFile:
// An old copy may have an old schema: it is brought up to date, after its own backup, before it is protected.
// Asked by the user: one more attempt, even after one that failed.
host.MigrationFailed = null;
await host.MigrateAsync(new Backups(config.Data, clock), ct).ConfigureAwait(false);
await Installation.RenewAsync(host.OpenForChoice(), config.Data, clock, "Database scelto dalla pagina d'errore", ct).ConfigureAwait(false);
break;
default:
return Results.Redirect("/?errore=scelta");
}
done = true;
}
catch (Exception ex) when (IsArchiveProblem(ex))
{
LogChoiceFailed(logger, ex, choice);
return Results.Redirect("/?errore=importazione");
}
finally
{
if (!done)
{
await host.AbandonChoiceAsync().ConfigureAwait(false);
}
}
host.KeepChoice();
LogChoice(logger, choice);
// Reset while the loop is still held: released first, it could start the application again before the reset