Skip to content

Commit bda4f73

Browse files
committed
Create a function to update max dict size for XZ
1 parent f50faa5 commit bda4f73

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

deb/tarfile.go

+13
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,19 @@ func DecompressorFor(ext string) DecompressorFunc {
8989
return func(r io.Reader) (io.ReadCloser, error) { return io.NopCloser(r), nil } // uncompressed file or unknown compression scheme
9090
}
9191

92+
// SetXZMaxDict updates the maximum dictionary size parameter for XZ
93+
// decompressing. If zero is supplied, the default max dictionary size will be
94+
// used.
95+
func SetXZMaxDict(maxDict uint32) {
96+
knownCompressionAlgorithms[".xz"] = func(r io.Reader) (io.ReadCloser, error) {
97+
reader, err := xz.NewReader(r, maxDict)
98+
if err != nil {
99+
return nil, err
100+
}
101+
return io.NopCloser(reader), nil
102+
}
103+
}
104+
92105
// }}}
93106

94107
// IsTarfile {{{

0 commit comments

Comments
 (0)