MCPcopy Create free account
hub / github.com/antonmedv/gitmal / inflateBinaryChunk

Function inflateBinaryChunk

pkg/gitdiff/binary.go:167–186  ·  view source on GitHub ↗
(frag *BinaryFragment, r io.Reader)

Source from the content-addressed store, hash-verified

165}
166
167func inflateBinaryChunk(frag *BinaryFragment, r io.Reader) error {
168 zr, err := zlib.NewReader(r)
169 if err != nil {
170 return err
171 }
172
173 data, err := ioutil.ReadAll(zr)
174 if err != nil {
175 return err
176 }
177 if err := zr.Close(); err != nil {
178 return err
179 }
180
181 if int64(len(data)) != frag.Size {
182 return fmt.Errorf("%d byte fragment inflated to %d", frag.Size, len(data))
183 }
184 frag.Data = data
185 return nil
186}

Callers 1

ParseBinaryChunkMethod · 0.85

Calls 2

ErrorfMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected