fix panic handler in NewCompressor (#987)

currently if newdecompressor panics, it will return nil, nil

this should make it return an error instead
This commit is contained in:
a 2023-05-07 22:40:38 -05:00 committed by GitHub
parent be83bbc58f
commit 7b16970501
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -143,13 +143,12 @@ func SetDecompressionTableCondensity(fromBitSize int) {
condensePatternTableBitThreshold = fromBitSize
}
func NewDecompressor(compressedFilePath string) (*Decompressor, error) {
func NewDecompressor(compressedFilePath string) (d *Decompressor, err error) {
_, fName := filepath.Split(compressedFilePath)
d := &Decompressor{
d = &Decompressor{
filePath: compressedFilePath,
fileName: fName,
}
var err error
defer func() {
if rec := recover(); rec != nil {
err = fmt.Errorf("decompressing file: %s, %+v, trace: %s", compressedFilePath, rec, dbg.Stack())