forked from TrueCloudLab/frostfs-s3-gw
[#514] Missed version id in tags
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
parent
64931c77f4
commit
93a7c2eaeb
4 changed files with 22 additions and 11 deletions
|
@ -66,7 +66,6 @@ func (h *handler) PutObjectTaggingHandler(w http.ResponseWriter, r *http.Request
|
|||
|
||||
func (h *handler) GetObjectTaggingHandler(w http.ResponseWriter, r *http.Request) {
|
||||
reqInfo := api.GetReqInfo(r.Context())
|
||||
versionID := reqInfo.URL.Query().Get("versionId")
|
||||
|
||||
bktInfo, err := h.getBucketAndCheckOwner(r, reqInfo.BucketName)
|
||||
if err != nil {
|
||||
|
@ -74,19 +73,27 @@ func (h *handler) GetObjectTaggingHandler(w http.ResponseWriter, r *http.Request
|
|||
return
|
||||
}
|
||||
|
||||
settings, err := h.obj.GetBucketSettings(r.Context(), bktInfo)
|
||||
if err != nil {
|
||||
h.logAndSendError(w, "could not get bucket settings", reqInfo, err)
|
||||
return
|
||||
}
|
||||
|
||||
p := &layer.ObjectVersion{
|
||||
BktInfo: bktInfo,
|
||||
ObjectName: reqInfo.ObjectName,
|
||||
VersionID: versionID,
|
||||
VersionID: reqInfo.URL.Query().Get("versionId"),
|
||||
}
|
||||
|
||||
tagSet, err := h.obj.GetObjectTagging(r.Context(), p)
|
||||
versionID, tagSet, err := h.obj.GetObjectTagging(r.Context(), p)
|
||||
if err != nil {
|
||||
h.logAndSendError(w, "could not get object tagging", reqInfo, err)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set(api.AmzVersionID, versionID)
|
||||
if settings.VersioningEnabled {
|
||||
w.Header().Set(api.AmzVersionID, versionID)
|
||||
}
|
||||
if err = api.EncodeToResponse(w, encodeTagging(tagSet)); err != nil {
|
||||
h.logAndSendError(w, "something went wrong", reqInfo, err)
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ func (n *layer) GetObjectTaggingAndLock(ctx context.Context, objVersion *ObjectV
|
|||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
objVersion.VersionID = version.OID.EncodeToString()
|
||||
|
||||
tags, lockInfo, err = n.treeService.GetObjectTaggingAndLock(ctx, &objVersion.BktInfo.CID, version)
|
||||
if err != nil {
|
||||
|
|
|
@ -224,7 +224,7 @@ type (
|
|||
PutBucketTagging(ctx context.Context, cnrID *cid.ID, tagSet map[string]string) error
|
||||
DeleteBucketTagging(ctx context.Context, cnrID *cid.ID) error
|
||||
|
||||
GetObjectTagging(ctx context.Context, p *ObjectVersion) (map[string]string, error)
|
||||
GetObjectTagging(ctx context.Context, p *ObjectVersion) (string, map[string]string, error)
|
||||
PutObjectTagging(ctx context.Context, p *ObjectVersion, tagSet map[string]string) error
|
||||
DeleteObjectTagging(ctx context.Context, p *ObjectVersion) error
|
||||
|
||||
|
|
|
@ -10,34 +10,36 @@ import (
|
|||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func (n *layer) GetObjectTagging(ctx context.Context, p *ObjectVersion) (map[string]string, error) {
|
||||
func (n *layer) GetObjectTagging(ctx context.Context, p *ObjectVersion) (string, map[string]string, error) {
|
||||
var (
|
||||
err error
|
||||
tags map[string]string
|
||||
)
|
||||
|
||||
tags = n.systemCache.GetTagging(objectTaggingCacheKey(p))
|
||||
if tags != nil {
|
||||
return tags, nil
|
||||
return p.VersionID, tags, nil
|
||||
}
|
||||
|
||||
version, err := n.getNodeVersion(ctx, p)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return "", nil, err
|
||||
}
|
||||
p.VersionID = version.OID.EncodeToString()
|
||||
|
||||
tags, err = n.treeService.GetObjectTagging(ctx, &p.BktInfo.CID, version)
|
||||
if err != nil {
|
||||
if errorsStd.Is(err, ErrNodeNotFound) {
|
||||
return nil, errors.GetAPIError(errors.ErrNoSuchKey)
|
||||
return "", nil, errors.GetAPIError(errors.ErrNoSuchKey)
|
||||
}
|
||||
return nil, err
|
||||
return "", nil, err
|
||||
}
|
||||
|
||||
if err = n.systemCache.PutTagging(objectTaggingCacheKey(p), tags); err != nil {
|
||||
n.log.Error("couldn't cache system object", zap.Error(err))
|
||||
}
|
||||
|
||||
return tags, nil
|
||||
return p.VersionID, tags, nil
|
||||
}
|
||||
|
||||
func (n *layer) PutObjectTagging(ctx context.Context, p *ObjectVersion, tagSet map[string]string) error {
|
||||
|
@ -45,6 +47,7 @@ func (n *layer) PutObjectTagging(ctx context.Context, p *ObjectVersion, tagSet m
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p.VersionID = version.OID.EncodeToString()
|
||||
|
||||
err = n.treeService.PutObjectTagging(ctx, &p.BktInfo.CID, version, tagSet)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue