From 208c785697d79b5e5fcdaa2ad1dc34135f882dfd Mon Sep 17 00:00:00 2001 From: Tamo Date: Sun, 16 Oct 2022 01:54:49 +0200 Subject: [PATCH] add a bufwriter on the documents --- dump/src/writer.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dump/src/writer.rs b/dump/src/writer.rs index d588022a5..b5c65e664 100644 --- a/dump/src/writer.rs +++ b/dump/src/writer.rs @@ -146,7 +146,7 @@ impl UpdateFile { } pub struct IndexWriter { - documents: File, + documents: BufWriter, settings: File, } @@ -161,7 +161,7 @@ impl IndexWriter { let settings = File::create(path.join("settings.json"))?; Ok(IndexWriter { - documents, + documents: BufWriter::new(documents), settings, }) } @@ -169,6 +169,7 @@ impl IndexWriter { pub fn push_document(&mut self, document: &Map) -> Result<()> { self.documents.write_all(&serde_json::to_vec(document)?)?; self.documents.write_all(b"\n")?; + self.documents.flush()?; Ok(()) }