From c6947f52e5647fc8b61b99d6250f831aa784251f Mon Sep 17 00:00:00 2001 From: Matt Dainty Date: Mon, 1 Apr 2024 23:46:33 +0100 Subject: [PATCH] style: Lint fixes --- internal/zstd/reader.go | 1 + reader.go | 4 +++- reader_test.go | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/zstd/reader.go b/internal/zstd/reader.go index 89f3993..0d68a3c 100644 --- a/internal/zstd/reader.go +++ b/internal/zstd/reader.go @@ -52,6 +52,7 @@ func NewReader(_ []byte, _ uint64, readers []io.ReadCloser) (io.ReadCloser, erro if r, err = zstd.NewReader(readers[0]); err != nil { return nil, err } + runtime.SetFinalizer(r, (*zstd.Decoder).Close) } diff --git a/reader.go b/reader.go index 8f586dd..6a2fdf8 100644 --- a/reader.go +++ b/reader.go @@ -544,7 +544,7 @@ func toValidName(name string) string { return p } -//nolint:cyclop +//nolint:cyclop,funlen func (z *Reader) initFileList() { z.fileListOnce.Do(func() { files := make(map[string]int) @@ -583,12 +583,14 @@ func (z *Reader) initFileList() { isDir: isDir, } z.fileList = append(z.fileList, entry) + if isDir { knownDirs[name] = idx } else { files[name] = idx } } + for dir := range dirs { if _, ok := knownDirs[dir]; !ok { if idx, ok := files[dir]; ok { diff --git a/reader_test.go b/reader_test.go index 578a19d..5b259d4 100644 --- a/reader_test.go +++ b/reader_test.go @@ -188,6 +188,7 @@ func TestOpenReader(t *testing.T) { t.Run(table.name, func(t *testing.T) { t.Parallel() + r, err := sevenzip.OpenReader(filepath.Join("testdata", table.file)) if err != nil { assert.ErrorIs(t, err, table.err) @@ -243,6 +244,7 @@ func TestOpenReaderWithPassword(t *testing.T) { t.Run(table.name, func(t *testing.T) { t.Parallel() + r, err := sevenzip.OpenReaderWithPassword(filepath.Join("testdata", table.file), table.password) if err != nil { t.Fatal(err)