use BufWriter
This commit is contained in:
parent
73f485eb59
commit
aed59f4663
@ -8,7 +8,7 @@ use async_zip::Compression;
|
||||
use std::path::PathBuf;
|
||||
use std::str::FromStr;
|
||||
use tokio::fs;
|
||||
use tokio::io::{AsyncBufReadExt, AsyncReadExt, BufReader};
|
||||
use tokio::io::{AsyncBufReadExt, AsyncReadExt, AsyncWriteExt, BufReader, BufWriter};
|
||||
use tokio::sync::mpsc::{self, UnboundedReceiver, UnboundedSender};
|
||||
|
||||
const INPUT_FILENAME: &str = "baza_utf8.zip";
|
||||
@ -312,8 +312,9 @@ async fn reader_converter(tx: UnboundedSender<ConvertedFile>) {
|
||||
|
||||
/// write json data to zip files
|
||||
async fn zip_writer(mut rx: UnboundedReceiver<ConvertedFile>) {
|
||||
let mut file = fs::File::create(OUTPUT_FILENAME).await.unwrap();
|
||||
let mut writer = ZipFileWriter::new(&mut file);
|
||||
let file = fs::File::create(OUTPUT_FILENAME).await.unwrap();
|
||||
let mut buf = BufWriter::with_capacity(100 * 1024 * 1024, file);
|
||||
let mut writer = ZipFileWriter::new(&mut buf);
|
||||
|
||||
while let Some(ConvertedFile { name, data }) = rx.recv().await {
|
||||
// make output filename
|
||||
@ -329,6 +330,7 @@ async fn zip_writer(mut rx: UnboundedReceiver<ConvertedFile>) {
|
||||
.unwrap();
|
||||
}
|
||||
writer.close().await.unwrap();
|
||||
buf.flush().await.unwrap();
|
||||
|
||||
println!("write done ✅");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user