@@ -879,13 +879,11 @@ func canMount(userAc *reqCtx.UserAccessControl, imgStore storageTypes.ImageStore
879879) (bool , error ) {
880880 canMount := true
881881
882- // authz enabled
883882 if userAc != nil {
884883 canMount = false
885884
886885 repos , err := imgStore .GetAllDedupeReposCandidates (digest )
887886 if err != nil {
888- // first write
889887 return false , err
890888 }
891889
@@ -943,9 +941,12 @@ func (rh *RouteHandler) CheckBlob(response http.ResponseWriter, request *http.Re
943941 return
944942 }
945943
946- userCanMount , err := canMount (userAc , imgStore , digest )
947- if err != nil {
948- rh .c .Log .Error ().Err (err ).Msg ("unexpected error" )
944+ userCanMount := true
945+ if rh .c .Config .IsAuthzEnabled () {
946+ userCanMount , err = canMount (userAc , imgStore , digest )
947+ if err != nil {
948+ rh .c .Log .Error ().Err (err ).Msg ("unexpected error" )
949+ }
949950 }
950951
951952 var blen int64
@@ -963,7 +964,7 @@ func (rh *RouteHandler) CheckBlob(response http.ResponseWriter, request *http.Re
963964
964965 if err != nil {
965966 details := zerr .GetDetails (err )
966- if errors .Is (err , zerr .ErrBadBlobDigest ) { //nolint:gocritic // errorslint conflicts with gocritic:IfElseChain
967+ if errors .Is (err , zerr .ErrBadBlobDigest ) { //nolint:gocritic,dupl // errorslint conflicts with gocritic:IfElseChain
967968 details ["digest" ] = digest .String ()
968969 e := apiErr .NewError (apiErr .DIGEST_INVALID ).AddDetail (details )
969970 zcommon .WriteJSON (response , http .StatusBadRequest , apiErr .NewErrorList (e ))
@@ -1254,9 +1255,12 @@ func (rh *RouteHandler) CreateBlobUpload(response http.ResponseWriter, request *
12541255 return
12551256 }
12561257
1257- userCanMount , err := canMount (userAc , imgStore , mountDigest )
1258- if err != nil {
1259- rh .c .Log .Error ().Err (err ).Msg ("unexpected error" )
1258+ userCanMount := true
1259+ if rh .c .Config .IsAuthzEnabled () {
1260+ userCanMount , err = canMount (userAc , imgStore , mountDigest )
1261+ if err != nil {
1262+ rh .c .Log .Error ().Err (err ).Msg ("unexpected error" )
1263+ }
12601264 }
12611265
12621266 // zot does not support cross mounting directly and do a workaround creating using hard link.
0 commit comments