From c1332c0d2dfd5d2145ed2398ece14d78e800da28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Saparelli?= Date: Tue, 17 Jan 2023 13:08:25 +1300 Subject: [PATCH] Revert "Bump async_zip from 0.0.9 to 0.0.10" (#714) --- Cargo.lock | 146 +++++++++++++++++- crates/binstalk-downloader/Cargo.toml | 2 +- .../src/download/async_extracter.rs | 6 +- .../src/download/zip_extraction.rs | 29 ++-- 4 files changed, 153 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a08b595d..99695ee6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -52,6 +52,15 @@ 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" @@ -82,14 +91,24 @@ dependencies = [ ] [[package]] -name = "async_zip" -version = "0.0.10" +name = "async_io_utilities" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5282f208287c58b7df1f7965531a49192eb4a22558fa1421d26d1a7c6118613" +checksum = "9b20cffc5590f4bf33f05f97a3ea587feba9c50d20325b401daa096b92ff7da0" +dependencies = [ + "tokio", +] + +[[package]] +name = "async_zip" +version = "0.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a36d43bdefc7215b2b3a97edd03b1553b7969ad76551025eedd3b913c645f6e" dependencies = [ "async-compression", + "async_io_utilities", + "chrono", "crc32fast", - "pin-project", "thiserror", "tokio", ] @@ -392,9 +411,14 @@ 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]] @@ -443,6 +467,16 @@ 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" @@ -520,6 +554,50 @@ dependencies = [ "typenum", ] +[[package]] +name = "cxx" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d1075c37807dcf850c379432f0df05ba52cc30f279c5cfc43cc221ce7f8579" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5044281f61b27bc598f2f6647d480aed48d2bf52d6eb0b627d84c0361b17aa70" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61b50bc93ba22c27b0d31128d2d130a0a6b3d267ae27ef7e4fae2167dfe8781c" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e61fda7e62115119469c7b3591fd913ecca96fb766cfd3f2e2502ab7bc87a5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "data-encoding" version = "2.3.3" @@ -829,7 +907,7 @@ checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", ] [[package]] @@ -1006,6 +1084,30 @@ 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" @@ -1177,6 +1279,15 @@ 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" @@ -1324,7 +1435,7 @@ checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" dependencies = [ "libc", "log", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys", ] @@ -1911,6 +2022,12 @@ 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" @@ -2222,6 +2339,17 @@ 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" @@ -2623,6 +2751,12 @@ 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 4b23c175..acf9d0e1 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.61" async-compression = { version = "0.3.15", features = ["gzip", "zstd", "xz", "bzip2", "tokio"] } -async_zip = { version = "0.0.10", features = ["deflate", "bzip2", "lzma", "zstd", "xz"] } +async_zip = { version = "0.0.9", features = ["deflate", "bzip2", "lzma", "zstd", "xz"] } binstalk-types = { version = "0.2.0", path = "../binstalk-types" } bytes = "1.3.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 6fd8d8a5..4850771e 100644 --- a/crates/binstalk-downloader/src/download/async_extracter.rs +++ b/crates/binstalk-downloader/src/download/async_extracter.rs @@ -48,10 +48,8 @@ where let mut zip = ZipFileReader::new(reader); let mut buf = BytesMut::with_capacity(4 * 4096); - 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?; - - zip = zip_reader.done().await.map_err(ZipError::from_inner)?; + while let Some(entry) = zip.entry_reader().await.map_err(ZipError::from_inner)? { + extract_zip_entry(entry, path, &mut buf).await?; } Ok(()) diff --git a/crates/binstalk-downloader/src/download/zip_extraction.rs b/crates/binstalk-downloader/src/download/zip_extraction.rs index 2f13a9e6..89e4f2ab 100644 --- a/crates/binstalk-downloader/src/download/zip_extraction.rs +++ b/crates/binstalk-downloader/src/download/zip_extraction.rs @@ -3,15 +3,12 @@ use std::{ path::{Component, Path, PathBuf}, }; -use async_zip::read::{ - seek::ZipEntryReader, - stream::{Reading, ZipFileReader}, -}; +use async_zip::{read::ZipEntryReader, ZipEntryExt}; use bytes::{Bytes, BytesMut}; use futures_util::future::{try_join, TryFutureExt}; use thiserror::Error as ThisError; use tokio::{ - io::{AsyncRead, AsyncReadExt, Take}, + io::{AsyncRead, AsyncReadExt}, sync::mpsc, }; @@ -37,7 +34,7 @@ impl ZipError { } pub(super) async fn extract_zip_entry( - zip_reader: &mut ZipFileReader>>, + entry: ZipEntryReader<'_, R>, path: &Path, buf: &mut BytesMut, ) -> Result<(), DownloadError> @@ -45,7 +42,7 @@ where R: AsyncRead + Unpin + Send + Sync, { // Sanitize filename - let raw_filename = zip_reader.entry().filename(); + let raw_filename = entry.entry().filename(); let filename = check_filename_and_normalize(raw_filename) .ok_or_else(|| ZipError(ZipErrorInner::InvalidFilePath(raw_filename.into())))?; @@ -59,7 +56,7 @@ where { use std::{fs::Permissions, os::unix::fs::PermissionsExt}; - if let Some(mode) = zip_reader.entry().unix_permissions() { + if let Some(mode) = entry.entry().unix_permissions() { let mode: u16 = mode; perms = Some(Permissions::from_mode(mode as u32)); } @@ -101,7 +98,7 @@ where Ok(()) }) .err_into(), - copy_file_to_mpsc(zip_reader.reader(), tx, buf) + copy_file_to_mpsc(entry, tx, buf) .map_err(ZipError::from_inner) .map_err(DownloadError::from), ) @@ -112,7 +109,7 @@ where } async fn copy_file_to_mpsc( - entry_reader: &mut ZipEntryReader<'_, R>, + mut entry: ZipEntryReader<'_, R>, tx: mpsc::Sender, buf: &mut BytesMut, ) -> Result<(), async_zip::error::ZipError> @@ -121,7 +118,7 @@ where { // Since BytesMut does not have a max cap, if AsyncReadExt::read_buf returns // 0 then it means Eof. - while entry_reader.read_buf(buf).await? != 0 { + while entry.read_buf(buf).await? != 0 { // Ensure AsyncReadExt::read_buf can read at least 4096B to avoid // frequent expensive read syscalls. // @@ -146,17 +143,11 @@ where } } - // With async_zip 0.0.10, ZipEntryReader::compare_crc is removed. - // Hopefully it will restored later. - - /* - if entry_reader.compare_crc() { + if entry.compare_crc() { Ok(()) } else { Err(async_zip::error::ZipError::CRC32CheckError) - }*/ - - Ok(()) + } } /// Ensure the file path is safe to use as a [`Path`].