Skip to content

Commit

Permalink
Fixed issues with decompress.Decoder
Browse files Browse the repository at this point in the history
  • Loading branch information
CalebQ42 committed Jan 5, 2023
1 parent 089ef53 commit ce2e45c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 13 deletions.
2 changes: 1 addition & 1 deletion internal/data/fullreader.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (r FullReader) process(index int, offset int64, out chan outDat) {
dat = make([]byte, size)
_, err = r.r.ReadAt(dat, offset)
if err == nil {
dat, err = dec.Decode(dat, int(r.blockSize))
dat, err = dec.Decode(dat)
}
} else {
rdr, err = r.d.Reader(io.LimitReader(toreader.NewReader(r.r, offset), int64(size)))
Expand Down
2 changes: 1 addition & 1 deletion internal/decompress/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ type Resetable interface {

type Decoder interface {
//Decodes a chunk of data all at once.
Decode(in []byte, outSize int) ([]byte, error)
Decode(in []byte) ([]byte, error)
}
9 changes: 0 additions & 9 deletions internal/decompress/lz4.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,3 @@ func (l Lz4) Reset(old, src io.Reader) error {
old.(*lz4.Reader).Reset(src)
return nil
}

func (l Lz4) Decode(in []byte, outSize int) (out []byte, err error) {
out = make([]byte, outSize)
outLen, err := lz4.UncompressBlock(in, out)
if outLen < outSize {
out = out[:outLen]
}
return
}
4 changes: 2 additions & 2 deletions internal/decompress/zstd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ func (z Zstd) Reset(old, src io.Reader) error {
return old.(*zstd.Decoder).Reset(src)
}

func (z Zstd) Decode(in []byte, outSize int) ([]byte, error) {
func (z Zstd) Decode(in []byte) ([]byte, error) {
if z.writeToReader == nil {
z.writeToReader, _ = zstd.NewReader(nil)
}
return z.writeToReader.DecodeAll(in, make([]byte, outSize))
return z.writeToReader.DecodeAll(in, nil)
}

0 comments on commit ce2e45c

Please sign in to comment.