(h plumbing.Hash)
| 282 | } |
| 283 | |
| 284 | func (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. |
no test coverage detected