MCPcopy
hub / github.com/git-lfs/git-lfs / prepareCacheDirectory

Method prepareCacheDirectory

locking/locks.go:435–456  ·  view source on GitHub ↗
(kind string)

Source from the content-addressed store, hash-verified

433}
434
435func (c *Client) prepareCacheDirectory(kind string) (string, error) {
436 cacheDir := filepath.Join(c.cacheDir, "locks")
437 if c.RemoteRef != nil {
438 cacheDir = filepath.Join(cacheDir, c.RemoteRef.Refspec())
439 }
440
441 stat, err := os.Stat(cacheDir)
442 if err == nil {
443 if !stat.IsDir() {
444 return cacheDir, errors.New(tr.Tr.Get("inititalization of cache directory %s failed: already exists, but is no directory", cacheDir))
445 }
446 } else if os.IsNotExist(err) {
447 err = tools.MkdirAll(cacheDir, c.cfg)
448 if err != nil {
449 return cacheDir, errors.Wrap(err, tr.Tr.Get("initiailization of cache directory %s failed: directory creation failed", cacheDir))
450 }
451 } else {
452 return cacheDir, errors.Wrap(err, tr.Tr.Get("initialization of cache directory %s failed", cacheDir))
453 }
454
455 return filepath.Join(cacheDir, kind), nil
456}
457
458func (c *Client) readLocksFromCacheFile(kind string, decoder func(*json.Decoder) error) error {
459 cacheFile, err := c.prepareCacheDirectory(kind)

Callers 4

writeLocksToCacheFileMethod · 0.95
TestRemoteLocksWithCacheFunction · 0.95

Calls 5

NewFunction · 0.92
MkdirAllFunction · 0.92
WrapFunction · 0.92
RefspecMethod · 0.80
GetMethod · 0.65

Tested by 2

TestRemoteLocksWithCacheFunction · 0.76