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

Method storePackfileInCache

storage/filesystem/object.go:250–282  ·  view source on GitHub ↗
(hash plumbing.Hash, p *packfile.Packfile)

Source from the content-addressed store, hash-verified

248}
249
250func (s *ObjectStorage) storePackfileInCache(hash plumbing.Hash, p *packfile.Packfile) error {
251 if s.options.KeepDescriptors {
252 s.packfiles[hash] = p
253 return nil
254 }
255
256 if s.options.MaxOpenDescriptors <= 0 {
257 return nil
258 }
259
260 // start over as the limit of packList is hit
261 if s.packListIdx >= len(s.packList) {
262 s.packListIdx = 0
263 }
264
265 // close the existing packfile if open
266 if next := s.packList[s.packListIdx]; !next.IsZero() {
267 open := s.packfiles[next]
268 delete(s.packfiles, next)
269 if open != nil {
270 if err := open.Close(); err != nil {
271 return err
272 }
273 }
274 }
275
276 // cache newly open packfile
277 s.packList[s.packListIdx] = hash
278 s.packfiles[hash] = p
279 s.packListIdx++
280
281 return nil
282}
283
284func (s *ObjectStorage) encodedObjectSizeFromPackfile(h plumbing.Hash) (
285 size int64, err error,

Callers 1

packfileMethod · 0.95

Calls 2

IsZeroMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected