From c202893563327a6de64f10b2f14b09cc61b16054 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Thu, 20 Jan 2022 17:36:21 +0300 Subject: [PATCH] [#307] Filter system metadata Signed-off-by: Denis Kirillov --- api/handler/get.go | 3 +++ api/layer/layer.go | 1 - api/layer/object.go | 4 ++++ api/layer/system_object.go | 5 ++++- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/api/handler/get.go b/api/handler/get.go index 23dbd5c0a..0bfeb924f 100644 --- a/api/handler/get.go +++ b/api/handler/get.go @@ -77,6 +77,9 @@ func writeHeaders(h http.Header, info *data.ObjectInfo, tagSetLength int) { h.Set(api.AmzTaggingCount, strconv.Itoa(tagSetLength)) for key, val := range info.Headers { + if layer.IsSystemHeader(key) { + continue + } h[api.MetadataPrefix+key] = []string{val} } } diff --git a/api/layer/layer.go b/api/layer/layer.go index 5aa2ccc31..367025eec 100644 --- a/api/layer/layer.go +++ b/api/layer/layer.go @@ -444,7 +444,6 @@ func (n *layer) GetBucketTagging(ctx context.Context, bucketName string) (map[st } objInfo, err := n.headSystemObject(ctx, bktInfo, formBucketTagObjectName(bucketName)) - if err != nil && !errors.IsS3Error(err, errors.ErrNoSuchKey) { return nil, err } diff --git a/api/layer/object.go b/api/layer/object.go index 020dcc7a0..790307e1d 100644 --- a/api/layer/object.go +++ b/api/layer/object.go @@ -546,6 +546,10 @@ func isSystem(obj *data.ObjectInfo) bool { len(obj.Headers[attrVersionsIgnore]) > 0 } +func IsSystemHeader(key string) bool { + return strings.HasPrefix(key, "S3-") +} + func trimAfterObjectName(startAfter string, objects []*data.ObjectInfo) []*data.ObjectInfo { if len(objects) != 0 && objects[len(objects)-1].Name <= startAfter { return nil diff --git a/api/layer/system_object.go b/api/layer/system_object.go index 6b347562f..d5b891e98 100644 --- a/api/layer/system_object.go +++ b/api/layer/system_object.go @@ -88,7 +88,10 @@ func (n *layer) putSystemObjectIntoNeoFS(ctx context.Context, p *PutSystemObject for k, v := range p.Metadata { attr := object.NewAttribute() - attr.SetKey(p.Prefix + k) + if !IsSystemHeader(k) { + k = p.Prefix + k + } + attr.SetKey(k) if p.Prefix == tagPrefix && v == "" { v = tagEmptyMark }