mirror of
https://github.com/EFForg/rayhunter.git
synced 2026-06-03 19:53:33 -07:00
simplify QmdlWriter
This commit is contained in:
+3
-12
@@ -37,18 +37,9 @@ where
|
||||
|
||||
pub async fn write_container(&mut self, container: &MessagesContainer) -> std::io::Result<()> {
|
||||
for msg in &container.messages {
|
||||
// for a gzipped file, we can't use `msg.data.len()` to
|
||||
// determine the number of bytes written, so we have to
|
||||
// manually do a `write_all()` type loop
|
||||
let mut buf = Cursor::new(&msg.data);
|
||||
loop {
|
||||
let bytes_written = self.writer.write_buf(&mut buf).await?;
|
||||
self.writer.flush().await?;
|
||||
if bytes_written == 0 {
|
||||
break;
|
||||
}
|
||||
self.total_uncompressed_bytes += bytes_written;
|
||||
}
|
||||
self.writer.write_all(&msg.data).await?;
|
||||
self.writer.flush().await?;
|
||||
self.total_uncompressed_bytes += msg.data.len();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user