use BufWriter
This commit is contained in:
parent
d48339b88b
commit
0ad014a544
@ -10,7 +10,7 @@ use encoding::label::encoding_from_whatwg_label;
|
||||
use encoding::EncodingRef;
|
||||
use encoding::{DecoderTrap, EncoderTrap};
|
||||
use regex::Regex;
|
||||
use tokio::io::AsyncReadExt;
|
||||
use tokio::io::{AsyncReadExt, BufWriter, AsyncWriteExt};
|
||||
use tokio::sync::mpsc::{self, UnboundedReceiver, UnboundedSender};
|
||||
use tokio::{fs, task};
|
||||
|
||||
@ -143,16 +143,18 @@ async fn writer_task(
|
||||
output_filename: String,
|
||||
compression: Compression,
|
||||
) {
|
||||
let mut outfile = fs::File::create(output_filename)
|
||||
let outfile = fs::File::create(output_filename)
|
||||
.await
|
||||
.expect("output file");
|
||||
let mut writer = ZipFileWriter::new(&mut outfile);
|
||||
let mut buf = BufWriter::with_capacity(100 * 1024 * 1024, outfile);
|
||||
let mut writer = ZipFileWriter::new(&mut buf);
|
||||
|
||||
while let Some(FileData { name, data }) = rx.recv().await {
|
||||
let opts = EntryOptions::new(name, compression);
|
||||
writer.write_entry_whole(opts, &data).await.unwrap();
|
||||
}
|
||||
writer.close().await.unwrap();
|
||||
buf.flush().await.unwrap();
|
||||
println!("write done ✅");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user