Avoid creating a default empty database in the search crate

This commit is contained in:
Clément Renault 2021-02-17 16:19:52 +01:00
parent 45330a5e47
commit b59fe77ec7
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4

View File

@ -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);