File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change 55 "io"
66 "os"
77 "path"
8+ "syscall"
89
910 "github.com/gofrs/flock"
1011 ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
@@ -36,15 +37,18 @@ func (s StoreIndex) Read() (*ocispecs.Index, error) {
3637 lock := flock .New (s .lockPath )
3738 locked , err := lock .TryRLock ()
3839 if err != nil {
39- return nil , errors .Wrapf (err , "could not lock %s" , s .lockPath )
40- }
41- if ! locked {
42- return nil , errors .Errorf ("could not lock %s" , s .lockPath )
40+ if ! errors .Is (err , syscall .EPERM ) && ! errors .Is (err , syscall .EROFS ) {
41+ return nil , errors .Wrapf (err , "could not lock %s" , s .lockPath )
42+ }
43+ } else {
44+ if ! locked {
45+ return nil , errors .Errorf ("could not lock %s" , s .lockPath )
46+ }
47+ defer func () {
48+ lock .Unlock ()
49+ os .RemoveAll (s .lockPath )
50+ }()
4351 }
44- defer func () {
45- lock .Unlock ()
46- os .RemoveAll (s .lockPath )
47- }()
4852
4953 b , err := os .ReadFile (s .indexPath )
5054 if err != nil {
You can’t perform that action at this time.
0 commit comments