Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions export_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package sevenzip

var ErrMissingUnpackInfo = errMissingUnpackInfo
10 changes: 9 additions & 1 deletion reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func TestOpenReader(t *testing.T) {
tables := []struct {
name, file string
volumes []string
err error
}{
{
name: "no header compression",
Expand Down Expand Up @@ -140,6 +141,11 @@ func TestOpenReader(t *testing.T) {
name: "issue 87",
file: "issue87.7z",
},
{
name: "issue 113",
file: "COMPRESS-492.7z",
err: sevenzip.ErrMissingUnpackInfo,
},
}

for _, table := range tables {
Expand All @@ -149,7 +155,9 @@ func TestOpenReader(t *testing.T) {
t.Parallel()
r, err := sevenzip.OpenReader(filepath.Join("testdata", table.file))
if err != nil {
t.Fatal(err)
assert.ErrorIs(t, err, table.err)

return
}
defer r.Close()

Expand Down
Binary file added testdata/COMPRESS-492.7z
Binary file not shown.
9 changes: 7 additions & 2 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ const (
)

var (
errIncompleteRead = errors.New("sevenzip: incomplete read")
errUnexpectedID = errors.New("sevenzip: unexpected id")
errIncompleteRead = errors.New("sevenzip: incomplete read")
errUnexpectedID = errors.New("sevenzip: unexpected id")
errMissingUnpackInfo = errors.New("sevenzip: missing unpack info")
)

func readUint64(r io.ByteReader) (uint64, error) {
Expand Down Expand Up @@ -510,6 +511,10 @@ func readStreamsInfo(r util.Reader) (*streamsInfo, error) {
}

if id == idSubStreamsInfo {
if s.unpackInfo == nil {
return nil, errMissingUnpackInfo
}

if s.subStreamsInfo, err = readSubStreamsInfo(r, s.unpackInfo.folder); err != nil {
return nil, err
}
Expand Down