fix(lib): Check db presence after dumps

This commit is contained in:
ad hoc 2022-04-27 10:41:09 +02:00
parent 04381011b0
commit 6025372565
No known key found for this signature in database
GPG Key ID: 4F00A782990CC643

View File

@ -178,15 +178,6 @@ impl IndexControllerBuilder {
.max_task_store_size .max_task_store_size
.ok_or_else(|| anyhow::anyhow!("Missing update database 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 { if let Some(ref path) = self.import_snapshot {
log::info!("Loading from snapshot {:?}", path); log::info!("Loading from snapshot {:?}", path);
load_snapshot( 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())?; std::fs::create_dir_all(db_path.as_ref())?;
let meta_env = Arc::new(open_meta_env(db_path.as_ref(), task_store_size)?); let meta_env = Arc::new(open_meta_env(db_path.as_ref(), task_store_size)?);