From 60253725650f60123d138fa198ebaa54dcb7157e Mon Sep 17 00:00:00 2001 From: ad hoc Date: Wed, 27 Apr 2022 10:41:09 +0200 Subject: [PATCH] fix(lib): Check db presence after dumps --- meilisearch-lib/src/index_controller/mod.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/meilisearch-lib/src/index_controller/mod.rs b/meilisearch-lib/src/index_controller/mod.rs index ae15e8abb..4cbba1e42 100644 --- a/meilisearch-lib/src/index_controller/mod.rs +++ b/meilisearch-lib/src/index_controller/mod.rs @@ -178,15 +178,6 @@ impl IndexControllerBuilder { .max_task_store_size .ok_or_else(|| anyhow::anyhow!("Missing update database size"))?; - let db_exists = db_path.as_ref().exists(); - if db_exists { - // Directory could be pre-created without any database in. - let db_is_empty = db_path.as_ref().read_dir()?.next().is_none(); - if !db_is_empty { - versioning::check_version_file(db_path.as_ref())?; - } - } - if let Some(ref path) = self.import_snapshot { log::info!("Loading from snapshot {:?}", path); load_snapshot( @@ -207,6 +198,15 @@ impl IndexControllerBuilder { )?; } + let db_exists = db_path.as_ref().exists(); + if db_exists { + // Directory could be pre-created without any database in. + let db_is_empty = db_path.as_ref().read_dir()?.next().is_none(); + if !db_is_empty { + versioning::check_version_file(db_path.as_ref())?; + } + } + std::fs::create_dir_all(db_path.as_ref())?; let meta_env = Arc::new(open_meta_env(db_path.as_ref(), task_store_size)?);