MCPcopy Create free account
hub / github.com/Unpackerr/unpackerr / buildZip

Function buildZip

pkg/unpackerr/folder_recursion_test.go:152–174  ·  view source on GitHub ↗
(entries map[string][]byte)

Source from the content-addressed store, hash-verified

150}
151
152func buildZip(entries map[string][]byte) ([]byte, error) {
153 var output bytes.Buffer
154
155 writer := zip.NewWriter(&output)
156 for name, data := range entries {
157 entry, err := writer.Create(name)
158 if err != nil {
159 _ = writer.Close()
160 return nil, fmt.Errorf("creating zip entry: %w", err)
161 }
162
163 if _, err := entry.Write(data); err != nil {
164 _ = writer.Close()
165 return nil, fmt.Errorf("creating zip entry: %w", err)
166 }
167 }
168
169 if err := writer.Close(); err != nil {
170 return nil, fmt.Errorf("closing zip writer: %w", err)
171 }
172
173 return output.Bytes(), nil
174}
175
176func containsFileBase(root, base string) bool {
177 var found bool

Callers 1

makeNestedZipFixtureFunction · 0.85

Calls 1

ErrorfMethod · 0.65

Tested by

no test coverage detected