[#389] Fix checks of bucket settings
In Put/CopyObject and PutBucketVersioning Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
This commit is contained in:
parent
c399cfbdda
commit
2b6843f8fa
3 changed files with 4 additions and 7 deletions
|
@ -249,9 +249,7 @@ func (h *handler) PutObjectHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if settings, err = h.obj.GetBucketSettings(r.Context(), bktInfo); err != nil {
|
if settings.VersioningEnabled {
|
||||||
h.log.Warn("couldn't get bucket versioning", zap.String("bucket name", reqInfo.BucketName), zap.Error(err))
|
|
||||||
} else if settings.VersioningEnabled {
|
|
||||||
w.Header().Set(api.AmzVersionID, info.Version())
|
w.Header().Set(api.AmzVersionID, info.Version())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,10 +62,6 @@ func (h *handler) GetBucketVersioningHandler(w http.ResponseWriter, r *http.Requ
|
||||||
|
|
||||||
settings, err := h.obj.GetBucketSettings(r.Context(), bktInfo)
|
settings, err := h.obj.GetBucketSettings(r.Context(), bktInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.IsS3Error(err, errors.ErrNoSuchBucket) {
|
|
||||||
h.logAndSendError(w, "couldn't get versioning settings", reqInfo, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
h.log.Warn("couldn't get version settings object: default version settings will be used",
|
h.log.Warn("couldn't get version settings object: default version settings will be used",
|
||||||
zap.String("request_id", reqInfo.RequestID),
|
zap.String("request_id", reqInfo.RequestID),
|
||||||
zap.String("method", reqInfo.API),
|
zap.String("method", reqInfo.API),
|
||||||
|
|
|
@ -239,6 +239,9 @@ func (n *layer) GetBucketSettings(ctx context.Context, bktInfo *data.BucketInfo)
|
||||||
|
|
||||||
obj, err := n.getSystemObjectFromNeoFS(ctx, bktInfo, bktInfo.SettingsObjectName())
|
obj, err := n.getSystemObjectFromNeoFS(ctx, bktInfo, bktInfo.SettingsObjectName())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if errors.IsS3Error(err, errors.ErrNoSuchKey) {
|
||||||
|
return &data.BucketSettings{}, nil
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue