From 45330a5e479d921e150c2a92c3929e78e2694235 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Wed, 17 Feb 2021 16:19:27 +0100 Subject: [PATCH] Avoid creating a default empty database in the infos crate --- infos/src/main.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/infos/src/main.rs b/infos/src/main.rs index 3f41b7d42..1ebf39969 100644 --- a/infos/src/main.rs +++ b/infos/src/main.rs @@ -200,6 +200,11 @@ fn run(opt: Opt) -> anyhow::Result<()> { let mut options = EnvOpenOptions::new(); options.map_size(opt.database_size.get_bytes() as usize); + // Return an error if the database does not exist. + if !opt.database.exists() { + anyhow::bail!("The database ({}) does not exist.", opt.database.display()); + } + // Open the LMDB database. let index = Index::new(options, opt.database)?; let rtxn = index.read_txn()?;