[#195] Check object locking when disable versioning

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
Denis Kirillov 2022-02-25 12:22:22 +03:00 committed by Angira Kekteeva
parent e98c663bd6
commit 3046d80b37

View file

@ -2,6 +2,7 @@ package handler
import ( import (
"encoding/xml" "encoding/xml"
"fmt"
"net/http" "net/http"
"github.com/nspcc-dev/neofs-s3-gw/api" "github.com/nspcc-dev/neofs-s3-gw/api"
@ -34,8 +35,14 @@ func (h *handler) PutBucketVersioningHandler(w http.ResponseWriter, r *http.Requ
return return
} }
if !p.Settings.VersioningEnabled && bktInfo.ObjectLockEnabled {
h.logAndSendError(w, "couldn't suspend bucket versioning", reqInfo, fmt.Errorf("object lock is enabled"))
return
}
if _, err := h.obj.PutBucketVersioning(r.Context(), p); err != nil { if _, err := h.obj.PutBucketVersioning(r.Context(), p); err != nil {
h.logAndSendError(w, "couldn't put update versioning settings", reqInfo, err) h.logAndSendError(w, "couldn't put update versioning settings", reqInfo, err)
return
} }
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
} }