File tree Expand file tree Collapse file tree 3 files changed +27
-33
lines changed Expand file tree Collapse file tree 3 files changed +27
-33
lines changed Original file line number Diff line number Diff line change 1
1
[package ]
2
2
name = " pnp"
3
- version = " 0.1 .0"
3
+ version = " 0.2 .0"
4
4
edition = " 2021"
5
5
license = " BSD-2-Clause"
6
6
description = " Resolution primitives for Yarn PnP"
@@ -13,8 +13,8 @@ repository = "https://github.com/yarnpkg/berry/"
13
13
clean-path = " 0.2.1"
14
14
fancy-regex = " 0.11.0"
15
15
lazy_static = " 1.4.0"
16
- libdeflater = " 0.12.0"
17
16
lru = " 0.10.0"
17
+ miniz_oxide = " 0.7.1"
18
18
path-slash = " 0.2.1"
19
19
pathdiff = " 0.2.1"
20
20
radix_trie = " 0.2.1"
@@ -24,4 +24,3 @@ serde_json = "1.0.93"
24
24
serde_with = " 2.2.0"
25
25
thiserror = " 1.0.39"
26
26
zip = { version = " 0.6.2" , default-features = false }
27
-
Original file line number Diff line number Diff line change @@ -25,6 +25,9 @@ pub enum Error {
25
25
#[ error( "Unsupported compression" ) ]
26
26
UnsupportedCompression ,
27
27
28
+ #[ error( "Decompression error" ) ]
29
+ DecompressionError ,
30
+
28
31
#[ error( transparent) ]
29
32
IOError ( #[ from] std:: io:: Error ) ,
30
33
@@ -96,23 +99,18 @@ impl Zip {
96
99
97
100
match entry. compression ( ) {
98
101
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 ) ?;
106
104
107
- Ok ( out )
105
+ Ok ( decompressed_data )
108
106
}
109
107
110
108
zip:: CompressionMethod :: STORE => {
111
- return Ok ( data)
109
+ Ok ( data)
112
110
}
113
111
114
112
_ => {
115
- return Err ( Error :: UnsupportedCompression ) ;
113
+ Err ( Error :: UnsupportedCompression )
116
114
}
117
115
}
118
116
}
You can’t perform that action at this time.
0 commit comments