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