Skip to content

Commit

Permalink
async_zipをv0.0.16に上げる (VOICEVOX#747)
Browse files Browse the repository at this point in the history
* async_zipをv0.0.16に上げる

* `async_zip::base::read::mem`を使う
  • Loading branch information
qryxip authored Feb 19, 2024
1 parent 5d13857 commit f9d956d
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 91 deletions.
89 changes: 41 additions & 48 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ anstyle-query = "1.0.0"
anyhow = "1.0.65"
assert_cmd = "2.0.8"
async-std = "1.12.0"
async_zip = "0.0.11"
async_zip = "=0.0.16"
binstall-tar = "0.4.39"
bytes = "1.1.0"
camino = "1.1.6"
Expand All @@ -33,6 +33,7 @@ fs-err = "2.9.0"
futures = "0.3.26"
futures-core = "0.3.25"
futures-util = "0.3.25"
futures-lite = "2.2.0"
heck = "0.4.1"
humansize = "2.1.2"
indexmap = "2.0.0"
Expand Down
3 changes: 2 additions & 1 deletion crates/test_util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name = "test_util"
edition.workspace = true

[dependencies]
async_zip = { workspace = true, features = ["full"] }
async_zip = { workspace = true, features = ["deflate"] }
futures-lite.workspace = true
once_cell.workspace = true
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
Expand Down
19 changes: 7 additions & 12 deletions crates/test_util/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
mod typing;

use async_zip::{write::ZipFileWriter, Compression, ZipEntryBuilder};
use async_zip::{base::write::ZipFileWriter, Compression, ZipEntryBuilder};
use futures_lite::AsyncWriteExt as _;
use once_cell::sync::Lazy;
use std::{
collections::HashMap,
path::{Path, PathBuf},
};
use tokio::{
fs::{self, File},
io::{AsyncReadExt, AsyncWriteExt},
io::AsyncReadExt,
sync::Mutex,
};

Expand Down Expand Up @@ -50,18 +51,11 @@ pub async fn convert_zip_vvm(dir: impl AsRef<Path>) -> PathBuf {
fs::create_dir_all(out_file_path.parent().unwrap())
.await
.unwrap();
let mut out_file = File::create(&out_file_path).await.unwrap();
let mut writer = ZipFileWriter::new(&mut out_file);
let mut writer = ZipFileWriter::new(vec![]);

for entry in dir.read_dir().unwrap().flatten() {
let entry_builder = ZipEntryBuilder::new(
entry
.path()
.file_name()
.unwrap()
.to_str()
.unwrap()
.to_string(),
entry.path().file_name().unwrap().to_str().unwrap().into(),
Compression::Deflate,
);
let mut entry_writer = writer.write_entry_stream(entry_builder).await.unwrap();
Expand All @@ -71,7 +65,8 @@ pub async fn convert_zip_vvm(dir: impl AsRef<Path>) -> PathBuf {
entry_writer.write_all(&buf).await.unwrap();
entry_writer.close().await.unwrap();
}
writer.close().await.unwrap();
let zip = writer.close().await.unwrap();
fs::write(&out_file_path, zip).await.unwrap();
}
out_file_path
}
2 changes: 1 addition & 1 deletion crates/voicevox_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ directml = ["onnxruntime/directml"]

[dependencies]
anyhow.workspace = true
async_zip = { workspace = true, features = ["full"] }
async_zip = { workspace = true, features = ["deflate"] }
camino.workspace = true
derive-getters.workspace = true
derive-new.workspace = true
Expand Down
Loading

0 comments on commit f9d956d

Please sign in to comment.