From b8ac80562ad6514af17220764f25cb8e8ebb0e97 Mon Sep 17 00:00:00 2001 From: Lucas Schwiderski Date: Wed, 15 May 2024 22:46:21 +0200 Subject: [PATCH] Update zip --- Cargo.lock | 135 ++++++++------------------------- Cargo.toml | 3 + crates/dtmm/Cargo.toml | 2 +- crates/dtmt/Cargo.toml | 2 +- crates/dtmt/src/cmd/package.rs | 28 ++----- 5 files changed, 43 insertions(+), 127 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a4be1c4..bd1f426 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,17 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aes" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" -dependencies = [ - "cfg-if", - "cipher", - "cpufeatures", -] - [[package]] name = "aho-corasick" version = "1.1.3" @@ -110,6 +99,15 @@ version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3" +[[package]] +name = "arbitrary" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" +dependencies = [ + "derive_arbitrary", +] + [[package]] name = "arrayref" version = "0.3.7" @@ -196,12 +194,6 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bincode" version = "1.3.3" @@ -382,16 +374,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "cipher" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" -dependencies = [ - "crypto-common", - "inout", -] - [[package]] name = "clang-sys" version = "1.7.0" @@ -580,12 +562,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "constant_time_eq" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - [[package]] name = "core-foundation" version = "0.9.4" @@ -737,6 +713,17 @@ dependencies = [ "serde", ] +[[package]] +name = "derive_arbitrary" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.63", +] + [[package]] name = "diff" version = "0.1.13" @@ -751,7 +738,6 @@ checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", "crypto-common", - "subtle", ] [[package]] @@ -1618,15 +1604,6 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest", -] - [[package]] name = "home" version = "0.5.9" @@ -1807,15 +1784,6 @@ dependencies = [ "libc", ] -[[package]] -name = "inout" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" -dependencies = [ - "generic-array", -] - [[package]] name = "instant" version = "0.1.12" @@ -2466,17 +2434,6 @@ dependencies = [ "system-deps", ] -[[package]] -name = "password-hash" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" -dependencies = [ - "base64ct", - "rand_core", - "subtle", -] - [[package]] name = "path-clean" version = "1.0.1" @@ -2495,18 +2452,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" -[[package]] -name = "pbkdf2" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" -dependencies = [ - "digest", - "hmac", - "password-hash", - "sha2", -] - [[package]] name = "percent-encoding" version = "2.3.1" @@ -3225,17 +3170,6 @@ dependencies = [ "serde", ] -[[package]] -name = "sha1" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - [[package]] name = "sha2" version = "0.10.8" @@ -3386,12 +3320,6 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - [[package]] name = "svgfilters" version = "0.4.0" @@ -4493,40 +4421,37 @@ checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" [[package]] name = "zip" -version = "0.6.6" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" +checksum = "f1f4a27345eb6f7aa7bd015ba7eb4175fa4e1b462a29874b779e0bbcf96c6ac7" dependencies = [ - "aes", - "byteorder", + "arbitrary", "bzip2", - "constant_time_eq", "crc32fast", "crossbeam-utils", + "displaydoc", "flate2", - "hmac", - "pbkdf2", - "sha1", + "indexmap", + "thiserror", "time", "zstd", ] [[package]] name = "zstd" -version = "0.11.2+zstd.1.5.2" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" +checksum = "2d789b1514203a1120ad2429eae43a7bd32b90976a7bb8a05f7ec02fa88cc23a" dependencies = [ "zstd-safe", ] [[package]] name = "zstd-safe" -version = "5.0.2+zstd.1.5.2" +version = "7.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" +checksum = "1cd99b45c6bc03a018c8b8a86025678c87e55526064e38f9df301989dce7ec0a" dependencies = [ - "libc", "zstd-sys", ] diff --git a/Cargo.toml b/Cargo.toml index 54cf161..39d8f38 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,9 @@ members = [ ] exclude = ["lib/color-eyre"] +[workspace.dependencies] +zip = { version = "1.3.0", default-features = false, features = ["deflate", "bzip2", "zstd", "time"] } + [patch.crates-io] color-eyre = { path = "lib/color-eyre" } ansi-parser = { git = "https://gitlab.com/lschwiderski/ansi-parser.git", branch = "issue/outdated-heapless" } diff --git a/crates/dtmm/Cargo.toml b/crates/dtmm/Cargo.toml index 627981b..ef862f3 100644 --- a/crates/dtmm/Cargo.toml +++ b/crates/dtmm/Cargo.toml @@ -38,4 +38,4 @@ tracing = "0.1.37" tracing-error = "0.2.0" tracing-subscriber = { version = "0.3.16", features = ["env-filter"] } usvg = "0.25.0" -zip = "0.6.4" +zip = { workspace = true } diff --git a/crates/dtmt/Cargo.toml b/crates/dtmt/Cargo.toml index baa21f8..d836a50 100644 --- a/crates/dtmt/Cargo.toml +++ b/crates/dtmt/Cargo.toml @@ -26,7 +26,7 @@ tokio = { version = "1.21.2", features = ["rt-multi-thread", "fs", "process", "m tracing-error = "0.2.0" tracing-subscriber = { version = "0.3.16", features = ["env-filter"] } tracing = { version = "0.1.37", features = ["async-await"] } -zip = "0.6.3" +zip = { workspace = true } path-clean = "1.0.1" path-slash = "0.2.1" async-recursion = "1.0.2" diff --git a/crates/dtmt/src/cmd/package.rs b/crates/dtmt/src/cmd/package.rs index e922b6e..5ded885 100644 --- a/crates/dtmt/src/cmd/package.rs +++ b/crates/dtmt/src/cmd/package.rs @@ -1,6 +1,5 @@ use std::io::{Cursor, Write}; use std::path::{Path, PathBuf}; -use std::sync::Arc; use clap::{value_parser, Arg, ArgMatches, Command}; use color_eyre::eyre::{Context, Result}; @@ -8,9 +7,9 @@ use color_eyre::Help; use dtmt_shared::ModConfig; use path_slash::{PathBufExt, PathExt}; use tokio::fs; -use tokio::sync::Mutex; use tokio_stream::wrappers::ReadDirStream; use tokio_stream::StreamExt; +use zip::write::SimpleFileOptions; use zip::ZipWriter; use crate::cmd::build::read_project_config; @@ -51,11 +50,7 @@ pub(crate) fn command_definition() -> Command { } #[async_recursion::async_recursion] -async fn process_directory( - zip: Arc>>, - path: P1, - prefix: P2, -) -> Result<()> +async fn process_directory(zip: &mut ZipWriter, path: P1, prefix: P2) -> Result<()> where P1: AsRef + std::marker::Send, P2: AsRef + std::marker::Send, @@ -64,9 +59,7 @@ where let path = path.as_ref(); let prefix = prefix.as_ref(); - zip.lock() - .await - .add_directory(prefix.to_slash_lossy(), Default::default())?; + zip.add_directory(prefix.to_slash_lossy(), SimpleFileOptions::default())?; let read_dir = fs::read_dir(&path) .await @@ -87,12 +80,11 @@ where .await .wrap_err_with(|| format!("Failed to read '{}'", in_path.display()))?; { - let mut zip = zip.lock().await; - zip.start_file(out_path.to_slash_lossy(), Default::default())?; + zip.start_file(out_path.to_slash_lossy(), SimpleFileOptions::default())?; zip.write_all(&data)?; } } else if t.is_dir() { - process_directory(zip.clone(), in_path, out_path).await?; + process_directory(zip, in_path, out_path).await?; } } @@ -107,16 +99,12 @@ where let path = path.as_ref(); let dest = dest.as_ref(); - let data = Cursor::new(Vec::new()); - let zip = ZipWriter::new(data); - let zip = Arc::new(Mutex::new(zip)); + let mut zip = ZipWriter::new(Cursor::new(Vec::with_capacity(1024))); - process_directory(zip.clone(), path, PathBuf::from(&cfg.id)) + process_directory(&mut zip, path, PathBuf::from(&cfg.id)) .await .wrap_err("Failed to add directory to archive")?; - let mut zip = zip.lock().await; - { let name = PathBuf::from(&cfg.id).join("dtmt.cfg"); let path = cfg.dir.join("dtmt.cfg"); @@ -125,7 +113,7 @@ where .await .wrap_err_with(|| format!("Failed to read mod config at {}", path.display()))?; - zip.start_file(name.to_slash_lossy(), Default::default())?; + zip.start_file(name.to_slash_lossy(), SimpleFileOptions::default())?; zip.write_all(&data)?; }