MCPcopy Create free account
hub / github.com/go-git/go-git / storePackfileInCache

Method storePackfileInCache

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

Source from the content-addressed store, hash-verified

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

Callers 1

packfileMethod · 0.95

Calls 2

IsZeroMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected