MCPcopy Create free account
hub / github.com/cli/cli / flockRefreshLock

Function flockRefreshLock

internal/config/refreshable.go:57–63  ·  view source on GitHub ↗

flockRefreshLock acquires the cross-process refresh lock with flock, creating the lock file's directory first. It is the production implementation used when AuthConfig.acquireRefreshLock is nil. Creating the directory here, behind the seam, keeps every filesystem effect of locking out of tests that

(ctx context.Context, path string)

Source from the content-addressed store, hash-verified

55// the production implementation used when AuthConfig.acquireRefreshLock is nil. Creating the directory here, behind the
56// seam, keeps every filesystem effect of locking out of tests that stub the seam.
57func flockRefreshLock(ctx context.Context, path string) (unlock func(), err error) {
58 if err := os.MkdirAll(filepath.Dir(path), 0771); err != nil {
59 return nil, err
60 }
61 _, unlock, err = flock.Lock(ctx, path)
62 return unlock, err
63}
64
65// isRefreshLockInaccessible reports whether err, returned while acquiring the refresh lock, shows that the lock file
66// or its directory cannot be created or opened because the filesystem denies the write. That is the case when gh runs

Calls 2

LockFunction · 0.92
MkdirAllMethod · 0.80