From faa3c652900811326000e7f1e9ee59dd4c1db002 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Mon, 30 May 2022 12:56:51 +0300 Subject: [PATCH] [#462] Fix None versioning status Signed-off-by: Denis Kirillov --- api/data/info.go | 1 + api/handler/versioning.go | 3 ++- api/layer/system_object.go | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/api/data/info.go b/api/data/info.go index b197a54dc..b8e48fca0 100644 --- a/api/data/info.go +++ b/api/data/info.go @@ -46,6 +46,7 @@ type ( // BucketSettings stores settings such as versioning. BucketSettings struct { + IsNoneStatus bool VersioningEnabled bool `json:"versioning_enabled"` LockConfiguration *ObjectLockConfiguration `json:"lock_configuration"` } diff --git a/api/handler/versioning.go b/api/handler/versioning.go index 30959db41..70e41fabe 100644 --- a/api/handler/versioning.go +++ b/api/handler/versioning.go @@ -34,6 +34,7 @@ func (h *handler) PutBucketVersioningHandler(w http.ResponseWriter, r *http.Requ } settings.VersioningEnabled = configuration.Status == "Enabled" + settings.IsNoneStatus = false p := &layer.PutSettingsParams{ BktInfo: bktInfo, @@ -76,7 +77,7 @@ func (h *handler) GetBucketVersioningHandler(w http.ResponseWriter, r *http.Requ func formVersioningConfiguration(settings *data.BucketSettings) *VersioningConfiguration { res := &VersioningConfiguration{} - if settings == nil { + if settings.IsNoneStatus { return res } if settings.VersioningEnabled { diff --git a/api/layer/system_object.go b/api/layer/system_object.go index 854cc07a1..1c13655a4 100644 --- a/api/layer/system_object.go +++ b/api/layer/system_object.go @@ -245,6 +245,7 @@ func (n *layer) GetBucketSettings(ctx context.Context, bktInfo *data.BucketInfo) if !errors.IsS3Error(err, errors.ErrNoSuchKey) { return nil, err } + settings.IsNoneStatus = true } else if err = json.Unmarshal(obj.Payload(), settings); err != nil { return nil, err }