fmt
This commit is contained in:
parent
5999e2bb92
commit
a0a3ea0fbb
19
src/main.rs
19
src/main.rs
@ -5,13 +5,13 @@ extern crate tokio;
|
||||
use async_zip::read::fs::ZipFileReader;
|
||||
use async_zip::write::{EntryOptions, ZipFileWriter};
|
||||
use async_zip::Compression;
|
||||
use std::collections::VecDeque;
|
||||
use std::path::PathBuf;
|
||||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
use tokio::fs;
|
||||
use tokio::io::{AsyncBufReadExt, AsyncReadExt, BufReader};
|
||||
use tokio::sync::Mutex;
|
||||
use tokio::fs;
|
||||
use std::collections::VecDeque;
|
||||
|
||||
const INPUT_FILENAME: &str = "baza_utf8.zip";
|
||||
const OUTPUT_FILENAME: &str = "json.zip";
|
||||
@ -224,7 +224,6 @@ async fn parse_file(
|
||||
Ok(ctx.data.clone())
|
||||
}
|
||||
|
||||
|
||||
struct WriteQueueItem {
|
||||
name: String,
|
||||
data: String,
|
||||
@ -234,7 +233,9 @@ type WriteQueue = Arc<Mutex<VecDeque<Option<WriteQueueItem>>>>;
|
||||
|
||||
async fn data_reader(queue: WriteQueue) {
|
||||
// open archive just to list files
|
||||
let archive = ZipFileReader::new(String::from(INPUT_FILENAME)).await.unwrap();
|
||||
let archive = ZipFileReader::new(String::from(INPUT_FILENAME))
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let source_files = archive
|
||||
.entries()
|
||||
@ -255,7 +256,10 @@ async fn data_reader(queue: WriteQueue) {
|
||||
let data = new_data.pretty(2);
|
||||
|
||||
// add to queue
|
||||
queue.lock().await.push_back(Some(WriteQueueItem { name, data }));
|
||||
queue
|
||||
.lock()
|
||||
.await
|
||||
.push_back(Some(WriteQueueItem { name, data }));
|
||||
}
|
||||
// mark queue as done for writer to exit loop
|
||||
queue.lock().await.push_back(None);
|
||||
@ -291,7 +295,10 @@ async fn data_writer(queue: WriteQueue) {
|
||||
let opts = EntryOptions::new(outfilename, Compression::Deflate);
|
||||
|
||||
// write new zip entry
|
||||
writer.write_entry_whole(opts, data.as_bytes()).await.unwrap();
|
||||
writer
|
||||
.write_entry_whole(opts, data.as_bytes())
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user