mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 12:05:05 +08:00
fix the deletion of the data.ms in case of failure
This commit is contained in:
parent
8d1408c65e
commit
ca4234b445
@ -144,8 +144,13 @@ pub fn setup_meilisearch(opt: &Opt) -> anyhow::Result<(IndexScheduler, AuthContr
|
|||||||
|
|
||||||
if empty_db && src_path_exists {
|
if empty_db && src_path_exists {
|
||||||
let (mut index_scheduler, mut auth_controller) = meilisearch_builder()?;
|
let (mut index_scheduler, mut auth_controller) = meilisearch_builder()?;
|
||||||
import_dump(&opt.db_path, path, &mut index_scheduler, &mut auth_controller)?;
|
match import_dump(&opt.db_path, path, &mut index_scheduler, &mut auth_controller) {
|
||||||
(index_scheduler, auth_controller)
|
Ok(()) => (index_scheduler, auth_controller),
|
||||||
|
Err(e) => {
|
||||||
|
std::fs::remove_dir_all(&opt.db_path)?;
|
||||||
|
return Err(e.into());
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if !empty_db && !opt.ignore_dump_if_db_exists {
|
} else if !empty_db && !opt.ignore_dump_if_db_exists {
|
||||||
bail!(
|
bail!(
|
||||||
"database already exists at {:?}, try to delete it or rename it",
|
"database already exists at {:?}, try to delete it or rename it",
|
||||||
@ -155,8 +160,13 @@ pub fn setup_meilisearch(opt: &Opt) -> anyhow::Result<(IndexScheduler, AuthContr
|
|||||||
bail!("dump doesn't exist at {:?}", path)
|
bail!("dump doesn't exist at {:?}", path)
|
||||||
} else {
|
} else {
|
||||||
let (mut index_scheduler, mut auth_controller) = meilisearch_builder()?;
|
let (mut index_scheduler, mut auth_controller) = meilisearch_builder()?;
|
||||||
import_dump(&opt.db_path, path, &mut index_scheduler, &mut auth_controller)?;
|
match import_dump(&opt.db_path, path, &mut index_scheduler, &mut auth_controller) {
|
||||||
(index_scheduler, auth_controller)
|
Ok(()) => (index_scheduler, auth_controller),
|
||||||
|
Err(e) => {
|
||||||
|
std::fs::remove_dir_all(&opt.db_path)?;
|
||||||
|
return Err(e.into());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
meilisearch_builder()?
|
meilisearch_builder()?
|
||||||
|
Loading…
Reference in New Issue
Block a user