From 0620f1a6827e85d61c12860a0fbb5cd28b2bf64c Mon Sep 17 00:00:00 2001 From: trivernis Date: Sun, 15 Mar 2020 11:00:47 +0100 Subject: [PATCH] Fix processing of empty chunk when finishing --- Cargo.toml | 2 +- src/io.rs | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fced60b..0acc814 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bdflib" -version = "0.3.2" +version = "0.3.3" authors = ["trivernis "] edition = "2018" license-file = "LICENSE" diff --git a/src/io.rs b/src/io.rs index 1a75d9b..104350e 100644 --- a/src/io.rs +++ b/src/io.rs @@ -164,10 +164,16 @@ impl BDFWriter { } self.thread_manager.sender_result.send(data_chunk.serialize()).expect("failed to send serialization result"); } + self.write_serialized()?; + self.data_entries = Vec::new(); + + Ok(()) + } + + fn write_serialized(&mut self) -> Result<(), Error> { while let Ok(data) = self.thread_manager.receiver_result.try_recv() { self.writer.write(data.as_slice())?; } - self.data_entries = Vec::new(); Ok(()) } @@ -184,7 +190,7 @@ impl BDFWriter { self.flush()?; self.thread_manager.drop_sender(); self.thread_manager.wait(); - self.flush()?; + self.write_serialized()?; self.flush_writer()?; Ok(())