From 4c3dac43e758952f92c2485ed2da73cb5588bd58 Mon Sep 17 00:00:00 2001 From: erhant Date: Thu, 2 Jul 2026 15:07:56 +0300 Subject: [PATCH] fix: copilot comments, add guards for missing configs --- src/lez_explorer_ui_backend.cpp | 8 ++++++++ src/qml/pages/SettingsPage.qml | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/src/lez_explorer_ui_backend.cpp b/src/lez_explorer_ui_backend.cpp index b5f0a1b..14b52a7 100644 --- a/src/lez_explorer_ui_backend.cpp +++ b/src/lez_explorer_ui_backend.cpp @@ -400,6 +400,14 @@ bool LezExplorerUiBackend::applyConfigJson(QString json) { } bool LezExplorerUiBackend::resetIndexerCache() { + // A saved config is required: reset_storage reads the channel from it, and we + // restart from it afterwards. Without one there's nothing to reset against, so + // don't wipe-then-fail-to-restart. + if (readConfigFile().trimmed().isEmpty()) { + emit error(QStringLiteral("Save an indexer config before deleting the cache.")); + return false; + } + // reset_storage stops the indexer and deletes its RocksDB store; then we // restart from the saved config so it re-indexes the current chain from // scratch. The recovery path for a store left stale against a reset chain. diff --git a/src/qml/pages/SettingsPage.qml b/src/qml/pages/SettingsPage.qml index d987b69..a95b1bd 100644 --- a/src/qml/pages/SettingsPage.qml +++ b/src/qml/pages/SettingsPage.qml @@ -155,6 +155,13 @@ Item { function resetCache() { if (!page.backend) return; + // Nothing to reset to until a config has been saved; don't arm the + // destructive confirm — point the user at Save first. + if (!page.backend.configText || page.backend.configText.length === 0) { + page.confirmingReset = false; + page.setStatus("Save an indexer config first, then you can delete the cache.", true); + return; + } if (!page.confirmingReset) { page.confirmingReset = true; page.setStatus("Click “Confirm delete” to wipe the local index and re-sync from scratch.", true);