always copy UserDefined metadata map (#10427)

fixes #10426
master
Harshavardhana 4 years ago committed by GitHub
parent a9aaea0d67
commit 9f60e84ce1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      cmd/erasure-multipart.go
  2. 21
      cmd/fs-v1.go

@ -267,10 +267,9 @@ func (er erasureObjects) newMultipartUpload(ctx context.Context, bucket string,
fi.DataDir = mustGetUUID()
fi.ModTime = UTCNow()
if opts.UserDefined != nil {
fi.Metadata = opts.UserDefined
} else {
fi.Metadata = make(map[string]string)
fi.Metadata = map[string]string{}
for k, v := range opts.UserDefined {
fi.Metadata[k] = v
}
uploadID := mustGetUUID()
@ -543,7 +542,10 @@ func (er erasureObjects) GetMultipartInfo(ctx context.Context, bucket, object, u
return result, err
}
result.UserDefined = fi.Metadata
result.UserDefined = map[string]string{}
for k, v := range fi.Metadata {
result.UserDefined[k] = v
}
return result, nil
}
@ -591,7 +593,10 @@ func (er erasureObjects) ListObjectParts(ctx context.Context, bucket, object, up
result.UploadID = uploadID
result.MaxParts = maxParts
result.PartNumberMarker = partNumberMarker
result.UserDefined = fi.Metadata
result.UserDefined = map[string]string{}
for k, v := range fi.Metadata {
result.UserDefined[k] = v
}
// For empty number of parts or maxParts as zero, return right here.
if len(fi.Parts) == 0 || maxParts == 0 {

@ -635,7 +635,10 @@ func (fs *FSObjects) CopyObject(ctx context.Context, srcBucket, srcObject, dstBu
fsMeta = fs.defaultFsJSON(srcObject)
}
fsMeta.Meta = srcInfo.UserDefined
fsMeta.Meta = map[string]string{}
for k, v := range srcInfo.UserDefined {
fsMeta.Meta[k] = v
}
fsMeta.Meta["etag"] = srcInfo.ETag
if _, err = fsMeta.WriteTo(wlk); err != nil {
return oi, toObjectErr(err, srcBucket, srcObject)
@ -885,10 +888,10 @@ func (fs *FSObjects) getObject(ctx context.Context, bucket, object string, offse
// Create a new fs.json file, if the existing one is corrupt. Should happen very rarely.
func (fs *FSObjects) createFsJSON(object, fsMetaPath string) error {
fsMeta := newFSMetaV1()
fsMeta.Meta = make(map[string]string)
fsMeta.Meta["etag"] = GenETag()
contentType := mimedb.TypeByExtension(path.Ext(object))
fsMeta.Meta["content-type"] = contentType
fsMeta.Meta = map[string]string{
"etag": GenETag(),
"content-type": mimedb.TypeByExtension(path.Ext(object)),
}
wlk, werr := fs.rwPool.Create(fsMetaPath)
if werr == nil {
_, err := fsMeta.WriteTo(wlk)
@ -901,10 +904,10 @@ func (fs *FSObjects) createFsJSON(object, fsMetaPath string) error {
// Used to return default etag values when a pre-existing object's meta data is queried.
func (fs *FSObjects) defaultFsJSON(object string) fsMetaV1 {
fsMeta := newFSMetaV1()
fsMeta.Meta = make(map[string]string)
fsMeta.Meta["etag"] = defaultEtag
contentType := mimedb.TypeByExtension(path.Ext(object))
fsMeta.Meta["content-type"] = contentType
fsMeta.Meta = map[string]string{
"etag": defaultEtag,
"content-type": mimedb.TypeByExtension(path.Ext(object)),
}
return fsMeta
}

Loading…
Cancel
Save