Fix Error decompressing files with lots of NULLs #24

This commit is contained in:
Caleb Gardner
2023-08-11 15:32:52 -05:00
parent 7e1a584e8f
commit 87f7533a17
5 changed files with 23 additions and 14 deletions
+8 -2
View File
@@ -14,15 +14,17 @@ type FullReader struct {
sizes []uint32
blockSize uint32
start uint64
fileSize uint64
}
func NewFullReader(r io.ReaderAt, start uint64, d decompress.Decompressor, blockSizes []uint32, blockSize uint32) *FullReader {
func NewFullReader(r io.ReaderAt, start uint64, d decompress.Decompressor, blockSizes []uint32, blockSize uint32, fileSize uint64) *FullReader {
return &FullReader{
r: r,
start: start,
blockSize: blockSize,
sizes: blockSizes,
d: d,
fileSize: fileSize,
}
}
@@ -43,10 +45,14 @@ func (r FullReader) process(index int, offset int64, out chan outDat) {
var rdr io.ReadCloser
size := realSize(r.sizes[index])
if size == 0 {
outSize := r.blockSize
if r.fileSize < uint64(r.blockSize) {
outSize = uint32(r.fileSize)
}
out <- outDat{
i: index,
err: nil,
data: make([]byte, r.blockSize),
data: make([]byte, outSize),
}
return
}