fix blocking writing of meta file in dump

This commit is contained in:
ad hoc 2022-06-07 10:07:40 +02:00
parent c3003065e8
commit cbd27d313c
No known key found for this signature in database
GPG Key ID: 4F00A782990CC643

View File

@ -22,6 +22,7 @@ mod real {
use meilisearch_auth::AuthController; use meilisearch_auth::AuthController;
use milli::heed::Env; use milli::heed::Env;
use tokio::fs::create_dir_all; use tokio::fs::create_dir_all;
use tokio::io::AsyncWriteExt;
use crate::analytics; use crate::analytics;
use crate::compression::to_tar_gz; use crate::compression::to_tar_gz;
@ -78,9 +79,11 @@ mod real {
let meta = MetadataVersion::new_v5(self.index_db_size, self.task_store_size); let meta = MetadataVersion::new_v5(self.index_db_size, self.task_store_size);
let meta_path = temp_dump_path.join(META_FILE_NAME); let meta_path = temp_dump_path.join(META_FILE_NAME);
// TODO: blocking
let mut meta_file = File::create(&meta_path)?; let meta_bytes = serde_json::to_vec(&meta)?;
serde_json::to_writer(&mut meta_file, &meta)?; let mut meta_file = tokio::fs::File::create(&meta_path).await?;
meta_file.write_all(&meta_bytes).await?;
analytics::copy_user_id(&self.db_path, &temp_dump_path); analytics::copy_user_id(&self.db_path, &temp_dump_path);
create_dir_all(&temp_dump_path.join("indexes")).await?; create_dir_all(&temp_dump_path.join("indexes")).await?;