From 0e055dbb7cf6cec8def678e886ea2c56302630c8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 22 Feb 2023 08:47:47 +0000 Subject: [PATCH] Bump async_zip from 0.0.9 to 0.0.12 (#824) --- Cargo.lock | 145 +----------------- crates/binstalk-downloader/Cargo.toml | 2 +- .../src/download/async_extracter.rs | 10 +- .../src/download/zip_extraction.rs | 24 ++- 4 files changed, 25 insertions(+), 156 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0723ddce..e847c56c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -52,15 +52,6 @@ dependencies = [ "alloc-no-stdlib", ] -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - [[package]] name = "async-compression" version = "0.3.15" @@ -90,25 +81,16 @@ dependencies = [ "syn", ] -[[package]] -name = "async_io_utilities" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b20cffc5590f4bf33f05f97a3ea587feba9c50d20325b401daa096b92ff7da0" -dependencies = [ - "tokio", -] - [[package]] name = "async_zip" -version = "0.0.9" +version = "0.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a36d43bdefc7215b2b3a97edd03b1553b7969ad76551025eedd3b913c645f6e" +checksum = "b2105142db9c6203b9dadc83b0553394589a6cb31b1449a3b46b42f47c3434d0" dependencies = [ "async-compression", - "async_io_utilities", - "chrono", "crc32fast", + "log", + "pin-project", "thiserror", "tokio", ] @@ -419,14 +401,9 @@ version = "0.4.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" dependencies = [ - "iana-time-zone", - "js-sys", "num-integer", "num-traits", "serde", - "time", - "wasm-bindgen", - "winapi", ] [[package]] @@ -475,16 +452,6 @@ dependencies = [ "cc", ] -[[package]] -name = "codespan-reporting" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" -dependencies = [ - "termcolor", - "unicode-width", -] - [[package]] name = "command-group" version = "2.0.1" @@ -564,50 +531,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "cxx" -version = "1.0.91" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86d3488e7665a7a483b57e25bdd90d0aeb2bc7608c8d0346acf2ad3f1caf1d62" -dependencies = [ - "cc", - "cxxbridge-flags", - "cxxbridge-macro", - "link-cplusplus", -] - -[[package]] -name = "cxx-build" -version = "1.0.91" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48fcaf066a053a41a81dfb14d57d99738b767febb8b735c3016e469fac5da690" -dependencies = [ - "cc", - "codespan-reporting", - "once_cell", - "proc-macro2", - "quote", - "scratch", - "syn", -] - -[[package]] -name = "cxxbridge-flags" -version = "1.0.91" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2ef98b8b717a829ca5603af80e1f9e2e48013ab227b68ef37872ef84ee479bf" - -[[package]] -name = "cxxbridge-macro" -version = "1.0.91" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "086c685979a698443656e5cf7856c95c642295a38599f12fb1ff76fb28d19892" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "data-encoding" version = "2.3.3" @@ -933,7 +856,7 @@ checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", ] [[package]] @@ -1116,30 +1039,6 @@ dependencies = [ "tokio-native-tls", ] -[[package]] -name = "iana-time-zone" -version = "0.1.53" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "winapi", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" -dependencies = [ - "cxx", - "cxx-build", -] - [[package]] name = "idna" version = "0.2.3" @@ -1311,15 +1210,6 @@ dependencies = [ "libc", ] -[[package]] -name = "link-cplusplus" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" -dependencies = [ - "cc", -] - [[package]] name = "linked-hash-map" version = "0.5.6" @@ -1467,7 +1357,7 @@ checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" dependencies = [ "libc", "log", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "windows-sys 0.45.0", ] @@ -2064,12 +1954,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "scratch" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" - [[package]] name = "sct" version = "0.7.0" @@ -2391,17 +2275,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "time" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" -dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi", -] - [[package]] name = "tinytemplate" version = "1.2.1" @@ -2837,12 +2710,6 @@ dependencies = [ "try-lock", ] -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" diff --git a/crates/binstalk-downloader/Cargo.toml b/crates/binstalk-downloader/Cargo.toml index c5e412a1..86491a98 100644 --- a/crates/binstalk-downloader/Cargo.toml +++ b/crates/binstalk-downloader/Cargo.toml @@ -12,7 +12,7 @@ license = "GPL-3.0" [dependencies] async-trait = "0.1.64" async-compression = { version = "0.3.15", features = ["gzip", "zstd", "xz", "bzip2", "tokio"] } -async_zip = { version = "0.0.9", features = ["deflate", "bzip2", "lzma", "zstd", "xz"] } +async_zip = { version = "0.0.12", features = ["deflate", "bzip2", "lzma", "zstd", "xz"] } binstalk-types = { version = "0.2.1", path = "../binstalk-types" } bytes = "1.4.0" bzip2 = "0.4.4" diff --git a/crates/binstalk-downloader/src/download/async_extracter.rs b/crates/binstalk-downloader/src/download/async_extracter.rs index 2c8115cc..7d7f0ffa 100644 --- a/crates/binstalk-downloader/src/download/async_extracter.rs +++ b/crates/binstalk-downloader/src/download/async_extracter.rs @@ -48,8 +48,14 @@ where let mut zip = ZipFileReader::new(reader); let mut buf = BytesMut::with_capacity(4 * 4096); - while let Some(entry) = zip.entry_reader().await.map_err(ZipError::from_inner)? { - extract_zip_entry(entry, path, &mut buf).await?; + while let Some(mut zip_reader) = zip.next_entry().await.map_err(ZipError::from_inner)? { + extract_zip_entry(&mut zip_reader, path, &mut buf).await?; + + // extract_zip_entry would read the zip_reader until read the file until + // eof unless extract_zip itself is cancelled or an error is raised. + // + // So calling done here should not raise any error. + zip = zip_reader.done().await.map_err(ZipError::from_inner)?; } Ok(()) diff --git a/crates/binstalk-downloader/src/download/zip_extraction.rs b/crates/binstalk-downloader/src/download/zip_extraction.rs index 69cfcb17..da708453 100644 --- a/crates/binstalk-downloader/src/download/zip_extraction.rs +++ b/crates/binstalk-downloader/src/download/zip_extraction.rs @@ -3,12 +3,12 @@ use std::{ path::{Component, Path, PathBuf}, }; -use async_zip::{read::ZipEntryReader, ZipEntryExt}; +use async_zip::read::stream::{Reading, ZipFileReader}; use bytes::{Bytes, BytesMut}; use futures_lite::future::try_zip as try_join; use thiserror::Error as ThisError; use tokio::{ - io::{AsyncRead, AsyncReadExt}, + io::{AsyncRead, AsyncReadExt, Take}, sync::mpsc, }; @@ -34,7 +34,7 @@ impl ZipError { } pub(super) async fn extract_zip_entry( - entry: ZipEntryReader<'_, R>, + zip_reader: &mut ZipFileReader>>, path: &Path, buf: &mut BytesMut, ) -> Result<(), DownloadError> @@ -42,7 +42,7 @@ where R: AsyncRead + Unpin + Send + Sync, { // Sanitize filename - let raw_filename = entry.entry().filename(); + let raw_filename = zip_reader.entry().filename(); let filename = check_filename_and_normalize(raw_filename) .ok_or_else(|| ZipError(ZipErrorInner::InvalidFilePath(raw_filename.into())))?; @@ -56,7 +56,7 @@ where { use std::{fs::Permissions, os::unix::fs::PermissionsExt}; - if let Some(mode) = entry.entry().unix_permissions() { + if let Some(mode) = zip_reader.entry().unix_permissions() { let mode: u16 = mode; perms = Some(Permissions::from_mode(mode as u32)); } @@ -98,7 +98,7 @@ where Ok(()) }); - let read_task = copy_file_to_mpsc(entry, tx, buf); + let read_task = copy_file_to_mpsc(zip_reader.reader(), tx, buf); try_join( async move { write_task.await.map_err(From::from) }, @@ -115,8 +115,8 @@ where Ok(()) } -async fn copy_file_to_mpsc( - mut entry: ZipEntryReader<'_, R>, +async fn copy_file_to_mpsc( + entry_reader: &mut R, tx: mpsc::Sender, buf: &mut BytesMut, ) -> Result<(), async_zip::error::ZipError> @@ -125,7 +125,7 @@ where { // Since BytesMut does not have a max cap, if AsyncReadExt::read_buf returns // 0 then it means Eof. - while entry.read_buf(buf).await? != 0 { + while entry_reader.read_buf(buf).await? != 0 { // Ensure AsyncReadExt::read_buf can read at least 4096B to avoid // frequent expensive read syscalls. // @@ -150,11 +150,7 @@ where } } - if entry.compare_crc() { - Ok(()) - } else { - Err(async_zip::error::ZipError::CRC32CheckError) - } + Ok(()) } /// Ensure the file path is safe to use as a [`Path`].