From b59fe77ec75c098b2c3c3599acd5a9a59432013b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Wed, 17 Feb 2021 16:19:52 +0100 Subject: [PATCH] Avoid creating a default empty database in the search crate --- search/src/main.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/search/src/main.rs b/search/src/main.rs index d2e727417..7e9443e5f 100644 --- a/search/src/main.rs +++ b/search/src/main.rs @@ -57,7 +57,11 @@ fn run(opt: Opt) -> anyhow::Result<()> { .timestamp(stderrlog::Timestamp::Off) .init()?; - std::fs::create_dir_all(&opt.database)?; + // Return an error if the database does not exist. + if !opt.database.exists() { + anyhow::bail!("The database ({}) does not exist.", opt.database.display()); + } + let mut options = EnvOpenOptions::new(); options.map_size(opt.database_size.get_bytes() as usize);