MCPcopy Create free account
hub / github.com/containerd/nerdctl / WithReadOnlyLock

Function WithReadOnlyLock

pkg/internal/filesystem/lock.go:116–127  ·  view source on GitHub ↗

WithReadOnlyLock executes the provided function after placing a read lock on `path`. The lock is released once the function has been run, regardless of outcome.

(path string, function func() error)

Source from the content-addressed store, hash-verified

114// WithReadOnlyLock executes the provided function after placing a read lock on `path`.
115// The lock is released once the function has been run, regardless of outcome.
116func WithReadOnlyLock(path string, function func() error) (err error) {
117 file, err := ReadOnlyLock(path)
118 if err != nil {
119 return err
120 }
121
122 defer func() {
123 err = errors.Join(Unlock(file), err)
124 }()
125
126 return function()
127}

Callers 4

TestLockMultiReadFunction · 0.92
TestLockWriteBlocksReadFunction · 0.92
fsReadFunction · 0.92

Calls 2

ReadOnlyLockFunction · 0.85
UnlockFunction · 0.70

Tested by 2

TestLockMultiReadFunction · 0.74
TestLockWriteBlocksReadFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…