(idx idxfile.Index, pack plumbing.Hash)
| 215 | } |
| 216 | |
| 217 | func (s *ObjectStorage) packfile(idx idxfile.Index, pack plumbing.Hash) (*packfile.Packfile, error) { |
| 218 | if p := s.packfileFromCache(pack); p != nil { |
| 219 | return p, nil |
| 220 | } |
| 221 | |
| 222 | f, err := s.dir.ObjectPack(pack) |
| 223 | if err != nil { |
| 224 | return nil, err |
| 225 | } |
| 226 | |
| 227 | var p *packfile.Packfile |
| 228 | if s.objectCache != nil { |
| 229 | p = packfile.NewPackfileWithCache(idx, s.dir.Fs(), f, s.objectCache, s.options.LargeObjectThreshold) |
| 230 | } else { |
| 231 | p = packfile.NewPackfile(idx, s.dir.Fs(), f, s.options.LargeObjectThreshold) |
| 232 | } |
| 233 | |
| 234 | return p, s.storePackfileInCache(pack, p) |
| 235 | } |
| 236 | |
| 237 | func (s *ObjectStorage) packfileFromCache(hash plumbing.Hash) *packfile.Packfile { |
| 238 | if s.packfiles == nil { |
no test coverage detected