forked from TrueCloudLab/frostfs-s3-gw
[#569] Refactor versioning in tree service
Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
This commit is contained in:
parent
e46763e429
commit
72013e08ec
10 changed files with 48 additions and 44 deletions
|
@ -33,15 +33,18 @@ func (h *handler) PutBucketVersioningHandler(w http.ResponseWriter, r *http.Requ
|
|||
return
|
||||
}
|
||||
|
||||
settings.VersioningEnabled = configuration.Status == "Enabled"
|
||||
settings.IsNoneStatus = false
|
||||
if configuration.Status != data.VerEnabled && configuration.Status != data.VerSuspended {
|
||||
h.logAndSendError(w, "invalid versioning configuration", reqInfo, err)
|
||||
return
|
||||
}
|
||||
settings.Versioning = configuration.Status
|
||||
|
||||
p := &layer.PutSettingsParams{
|
||||
BktInfo: bktInfo,
|
||||
Settings: settings,
|
||||
}
|
||||
|
||||
if !p.Settings.VersioningEnabled && bktInfo.ObjectLockEnabled {
|
||||
if p.Settings.VersioningSuspended() && bktInfo.ObjectLockEnabled {
|
||||
h.logAndSendError(w, "couldn't suspend bucket versioning", reqInfo, fmt.Errorf("object lock is enabled"))
|
||||
return
|
||||
}
|
||||
|
@ -77,13 +80,9 @@ func (h *handler) GetBucketVersioningHandler(w http.ResponseWriter, r *http.Requ
|
|||
|
||||
func formVersioningConfiguration(settings *data.BucketSettings) *VersioningConfiguration {
|
||||
res := &VersioningConfiguration{}
|
||||
if settings.IsNoneStatus {
|
||||
return res
|
||||
}
|
||||
if settings.VersioningEnabled {
|
||||
res.Status = "Enabled"
|
||||
} else {
|
||||
res.Status = "Suspended"
|
||||
if !settings.Unversioned() {
|
||||
res.Status = settings.Versioning
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue