MCPcopy Index your code
hub / github.com/go-git/go-git / encodedObjectSizeFromPackfile

Method encodedObjectSizeFromPackfile

storage/filesystem/object.go:284–317  ·  view source on GitHub ↗
(h plumbing.Hash)

Source from the content-addressed store, hash-verified

282}
283
284func (s *ObjectStorage) encodedObjectSizeFromPackfile(h plumbing.Hash) (
285 size int64, err error,
286) {
287 if err := s.requireIndex(); err != nil {
288 return 0, err
289 }
290
291 pack, _, offset := s.findObjectInPackfile(h)
292 if offset == -1 {
293 return 0, plumbing.ErrObjectNotFound
294 }
295
296 idx := s.index[pack]
297 hash, err := idx.FindHash(offset)
298 if err == nil {
299 obj, ok := s.objectCache.Get(hash)
300 if ok {
301 return obj.Size(), nil
302 }
303 } else if err != nil && err != plumbing.ErrObjectNotFound {
304 return 0, err
305 }
306
307 p, err := s.packfile(idx, pack)
308 if err != nil {
309 return 0, err
310 }
311
312 if !s.options.KeepDescriptors && s.options.MaxOpenDescriptors == 0 {
313 defer ioutil.CheckClose(p, &err)
314 }
315
316 return p.GetSizeByOffset(offset)
317}
318
319// EncodedObjectSize returns the plaintext size of the given object,
320// without actually reading the full object data from storage.

Callers 1

EncodedObjectSizeMethod · 0.95

Calls 8

requireIndexMethod · 0.95
findObjectInPackfileMethod · 0.95
packfileMethod · 0.95
CheckCloseFunction · 0.92
GetSizeByOffsetMethod · 0.80
FindHashMethod · 0.65
GetMethod · 0.65
SizeMethod · 0.65

Tested by

no test coverage detected