Skip to content

Commit

Permalink
Create a pool for each folder
Browse files Browse the repository at this point in the history
  • Loading branch information
bodgit committed May 2, 2022
1 parent bfdd7e6 commit d50f5dd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 11 additions & 0 deletions reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"time"

"github.com/bodgit/plumbing"
"github.com/bodgit/sevenzip/internal/pool"
"github.com/bodgit/sevenzip/internal/util"
"github.com/bodgit/windows"
"github.com/hashicorp/go-multierror"
Expand All @@ -33,13 +34,16 @@ var (
errIncompleteRead = errors.New("sevenzip: incomplete read")
)

var newPool pool.Constructor = pool.NewPool

type Reader struct {
r io.ReaderAt
start int64
end int64
si *streamsInfo
p string
File []*File
pool []pool.Pooler
}

type ReadCloser struct {
Expand Down Expand Up @@ -1077,6 +1081,13 @@ func (z *Reader) init(r io.ReaderAt, size int64) error {

z.si = header.streamsInfo

z.pool = make([]pool.Pooler, z.si.Folders())
for i := range z.pool {
if z.pool[i], err = newPool(); err != nil {
return err
}
}

// spew.Dump(header)

folder, offset := 0, int64(0)
Expand Down
6 changes: 5 additions & 1 deletion struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,11 @@ type streamsInfo struct {
}

func (si *streamsInfo) Folders() int {
return len(si.unpackInfo.folder)
if si != nil && si.unpackInfo != nil {
return len(si.unpackInfo.folder)
}

return 0
}

func (si *streamsInfo) FileFolderAndSize(file int) (int, uint64) {
Expand Down

0 comments on commit d50f5dd

Please sign in to comment.