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 5
5
"io"
6
6
"os"
7
7
"path"
8
+ "syscall"
8
9
9
10
"github.com/gofrs/flock"
10
11
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
@@ -36,15 +37,18 @@ func (s StoreIndex) Read() (*ocispecs.Index, error) {
36
37
lock := flock .New (s .lockPath )
37
38
locked , err := lock .TryRLock ()
38
39
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
+ }()
43
51
}
44
- defer func () {
45
- lock .Unlock ()
46
- os .RemoveAll (s .lockPath )
47
- }()
48
52
49
53
b , err := os .ReadFile (s .indexPath )
50
54
if err != nil {
You can’t perform that action at this time.
0 commit comments