Skip to content

Commit

Permalink
fix #244
Browse files Browse the repository at this point in the history
  • Loading branch information
richardlehane committed Jun 20, 2024
1 parent b25771d commit ca32689
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/sf/sf.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func identifyRdr(r io.Reader, ctx *context, ctxts chan *context, gf getFn) {
ctx.res <- results{err, cs, ids}
return
}
d, err := decompress.New(arc, b, ctx.path, ctx.sz)
d, err := decompress.New(arc, b, ctx.path)
if err != nil {
ctx.res <- results{fmt.Errorf("failed to decompress, got: %v", err), cs, ids}
return
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/siegfried.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var siegfried = struct {
checkpoint int64
userAgent string
}{
version: [3]int{1, 11, 0},
version: [3]int{1, 11, 1},
signature: "default.sig",
conf: "sf.conf",
magic: []byte{'s', 'f', 0x00, 0xFF},
Expand Down
10 changes: 6 additions & 4 deletions pkg/decompress/decompress.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ type Decompressor interface {
Dirs() []string
}

func New(arc config.Archive, buf *siegreader.Buffer, path string, sz int64) (Decompressor, error) {
func New(arc config.Archive, buf *siegreader.Buffer, path string) (Decompressor, error) {
switch arc {
case config.Zip:
return newZip(siegreader.ReaderFrom(buf), path, sz)
return newZip(buf, path)
case config.Gzip:
return newGzip(buf, path)
case config.Tar:
Expand All @@ -85,8 +85,10 @@ type zipD struct {
written map[string]bool
}

func newZip(ra io.ReaderAt, path string, sz int64) (Decompressor, error) {
zr, err := zip.NewReader(ra, sz)
func newZip(b *siegreader.Buffer, path string) (Decompressor, error) {
b.Quit = make(chan struct{}) // in case a stream with a closed quit channel, make a new one
sz := b.SizeNow() // in case a stream, force full read
zr, err := zip.NewReader(siegreader.ReaderFrom(b), sz)
return &zipD{idx: -1, p: path, rdr: zr}, err
}

Expand Down

0 comments on commit ca32689

Please sign in to comment.