MCPcopy Create free account
hub / github.com/bodgit/sevenzip / extractArchive

Function extractArchive

reader_test.go:60–91  ·  view source on GitHub ↗

nolint:lll

(tb testing.TB, r *sevenzip.Reader, stream int, h hash.Hash, fn func(io.Reader) io.Reader, optimised bool)

Source from the content-addressed store, hash-verified

58
59//nolint:lll
60func extractArchive(tb testing.TB, r *sevenzip.Reader, stream int, h hash.Hash, fn func(io.Reader) io.Reader, optimised bool) (err error) {
61 tb.Helper()
62
63 for _, f := range r.File {
64 if stream >= 0 && f.Stream != stream {
65 continue
66 }
67
68 var rc io.ReadCloser
69
70 rc, err = f.Open()
71 if err != nil {
72 return fmt.Errorf("error opening file: %w", err)
73 }
74
75 defer func() {
76 err = errors.Join(err, rc.Close())
77 }()
78
79 if err = extractFile(tb, fn(rc), h, f); err != nil {
80 return err
81 }
82
83 if optimised {
84 if err = rc.Close(); err != nil {
85 return fmt.Errorf("error closing: %w", err)
86 }
87 }
88 }
89
90 return nil
91}
92
93//nolint:funlen
94func TestOpenReader(t *testing.T) {

Callers 6

TestOpenReaderFunction · 0.85
TestNewReaderFunction · 0.85
benchmarkArchiveParallelFunction · 0.85
benchmarkArchiveFunction · 0.85

Calls 3

CloseMethod · 0.95
extractFileFunction · 0.85
OpenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…