Skip to content

Commit 39e4ed0

Browse files
committed
wip
1 parent 3417711 commit 39e4ed0

File tree

3 files changed

+27
-33
lines changed

3 files changed

+27
-33
lines changed

Cargo.lock

Lines changed: 17 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pnp"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
edition = "2021"
55
license = "BSD-2-Clause"
66
description = "Resolution primitives for Yarn PnP"
@@ -13,8 +13,8 @@ repository = "https://github.com/yarnpkg/berry/"
1313
clean-path = "0.2.1"
1414
fancy-regex = "0.11.0"
1515
lazy_static = "1.4.0"
16-
libdeflater = "0.12.0"
1716
lru = "0.10.0"
17+
miniz_oxide = "0.7.1"
1818
path-slash = "0.2.1"
1919
pathdiff = "0.2.1"
2020
radix_trie = "0.2.1"
@@ -24,4 +24,3 @@ serde_json = "1.0.93"
2424
serde_with = "2.2.0"
2525
thiserror = "1.0.39"
2626
zip = { version = "0.6.2", default-features = false }
27-

src/fs.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ pub enum Error {
2525
#[error("Unsupported compression")]
2626
UnsupportedCompression,
2727

28+
#[error("Decompression error")]
29+
DecompressionError,
30+
2831
#[error(transparent)]
2932
IOError(#[from] std::io::Error),
3033

@@ -96,23 +99,18 @@ impl Zip {
9699

97100
match entry.compression() {
98101
zip::CompressionMethod::DEFLATE => {
99-
let mut out = Vec::new();
100-
out.resize(entry.size() as usize, 0);
101-
102-
libdeflater::Decompressor::new().deflate_decompress(
103-
&data,
104-
&mut out,
105-
).unwrap();
102+
let decompressed_data = miniz_oxide::inflate::decompress_to_vec(&data)
103+
.map_err(|_e| Error::DecompressionError)?;
106104

107-
Ok(out)
105+
Ok(decompressed_data)
108106
}
109107

110108
zip::CompressionMethod::STORE => {
111-
return Ok(data)
109+
Ok(data)
112110
}
113111

114112
_ => {
115-
return Err(Error::UnsupportedCompression);
113+
Err(Error::UnsupportedCompression)
116114
}
117115
}
118116
}

0 commit comments

Comments
 (0)