about summary refs log tree commit diff
path: root/src/bin
diff options
context:
space:
mode:
authorAlexander_Kabui <alexanderkabui@proton.me>2026-10-14 08:36:18 +0300
committerAlexander_Kabui <alexanderkabui@proton.me>2026-10-14 08:36:18 +0300
commitdfa576b0f821dc8a0beba7acebeed81dc831b17a (patch)
tree5e086108c3afe303ed1707289f0c25635670e8e9 /src/bin
parent630fec9b00e85436638b93ebf8902579ae436247 (diff)
parent22ff53e2d65e47df27d76aa7420a146074c00282 (diff)
downloadgenenetwork4-dfa576b0f821dc8a0beba7acebeed81dc831b17a.tar.gz
Merge remote-tracking branch 'origin/gn4-devdb-switch' into gn4-integration
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/gn-indexer.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/bin/gn-indexer.rs b/src/bin/gn-indexer.rs
index 57a3f57..2149669 100644
--- a/src/bin/gn-indexer.rs
+++ b/src/bin/gn-indexer.rs
@@ -72,6 +72,20 @@ fn main() -> ExitCode {
         publish_filter,
     };
 
+    // Fail loudly BEFORE touching the index when the database is
+    // unreachable: the crawl needs it, and a run must never build an
+    // empty index. The message names SQL_URI/GN4_DB_MODE so the cause is
+    // unambiguous. (The crawl itself also fails, but this makes the
+    // reason explicit and keeps the index untouched by construction.)
+    if let Err(error) = genenetwork4::db::probe() {
+        eprintln!(
+            "gn-indexer: database unreachable (SQL_URI; GN4_DB_MODE={:?}); refusing to build an \
+             index: {error}",
+            config.db_mode
+        );
+        return ExitCode::from(1);
+    }
+
     let result = match mode.as_str() {
         "full" => run_full(&run_config),
         "incremental" => run_incremental(&run_config),