From 3046d80b37883c60a22d6a31e4a341af7ce97e08 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Fri, 25 Feb 2022 12:22:22 +0300 Subject: [PATCH] [#195] Check object locking when disable versioning Signed-off-by: Denis Kirillov --- api/handler/versioning.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/api/handler/versioning.go b/api/handler/versioning.go index 072c3b2d..6e3c899a 100644 --- a/api/handler/versioning.go +++ b/api/handler/versioning.go @@ -2,6 +2,7 @@ package handler import ( "encoding/xml" + "fmt" "net/http" "github.com/nspcc-dev/neofs-s3-gw/api" @@ -34,8 +35,14 @@ func (h *handler) PutBucketVersioningHandler(w http.ResponseWriter, r *http.Requ 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 { h.logAndSendError(w, "couldn't put update versioning settings", reqInfo, err) + return } w.WriteHeader(http.StatusOK) }