From f68c2574521c5e7fec1e12c5587a7b5f2476c526 Mon Sep 17 00:00:00 2001 From: marin postma Date: Wed, 23 Jun 2021 16:34:07 +0200 Subject: [PATCH] move flush in write_to_file function --- meilisearch-http/src/index_controller/update_actor/actor.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/meilisearch-http/src/index_controller/update_actor/actor.rs b/meilisearch-http/src/index_controller/update_actor/actor.rs index 5b269ea9a..5bc2c727e 100644 --- a/meilisearch-http/src/index_controller/update_actor/actor.rs +++ b/meilisearch-http/src/index_controller/update_actor/actor.rs @@ -145,11 +145,15 @@ where D: AsRef<[u8]> + Sized + 'static, { let mut file_len = 0; + while let Some(bytes) = payload.recv().await { let bytes = bytes?; file_len += bytes.as_ref().len(); file.write_all(bytes.as_ref()).await?; } + + file.flush().await?; + Ok(file_len) } @@ -157,7 +161,6 @@ where match file_len { Ok(len) if len > 0 => { - file.flush().await?; let file = file.into_std().await; Some((file, update_file_id)) }