From cbd27d313c27efc1de750f91e6b3c69e0d877c44 Mon Sep 17 00:00:00 2001 From: ad hoc Date: Tue, 7 Jun 2022 10:07:40 +0200 Subject: [PATCH] fix blocking writing of meta file in dump --- meilisearch-lib/src/dump/handler.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/meilisearch-lib/src/dump/handler.rs b/meilisearch-lib/src/dump/handler.rs index 4adb7011a..16bfd6a55 100644 --- a/meilisearch-lib/src/dump/handler.rs +++ b/meilisearch-lib/src/dump/handler.rs @@ -22,6 +22,7 @@ mod real { use meilisearch_auth::AuthController; use milli::heed::Env; use tokio::fs::create_dir_all; + use tokio::io::AsyncWriteExt; use crate::analytics; 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_path = temp_dump_path.join(META_FILE_NAME); - // TODO: blocking - let mut meta_file = File::create(&meta_path)?; - serde_json::to_writer(&mut meta_file, &meta)?; + + let meta_bytes = serde_json::to_vec(&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); create_dir_all(&temp_dump_path.join("indexes")).await?;