[#462] Fix None versioning status

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
Denis Kirillov 2022-05-30 12:56:51 +03:00 committed by Kirillov Denis
parent 0e37242b65
commit faa3c65290
3 changed files with 4 additions and 1 deletions

View file

@ -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"`
}

View file

@ -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 {

View file

@ -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
}