From 0e745fdb059aacbe7ed35bf99a4b4a3960e2ea9f Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Mon, 15 Aug 2016 15:20:06 -0700 Subject: [PATCH] fs: Enable fs.json with env MINIO_ENABLE_FSMETA --- fs-v1-metadata.go | 4 ++++ fs-v1-multipart.go | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/fs-v1-metadata.go b/fs-v1-metadata.go index 42ba70c1b..79b07f7b8 100644 --- a/fs-v1-metadata.go +++ b/fs-v1-metadata.go @@ -18,6 +18,7 @@ package main import ( "encoding/json" + "os" "path" "sort" "strings" @@ -161,6 +162,9 @@ func isExtendedHeader(header string) bool { // Return true if extended HTTP headers are set, false otherwise. func hasExtendedHeader(metadata map[string]string) bool { + if os.Getenv("MINIO_ENABLE_FSMETA") == "1" { + return true + } for k := range metadata { if isExtendedHeader(k) { return true diff --git a/fs-v1-multipart.go b/fs-v1-multipart.go index bc45abefc..b494d94bf 100644 --- a/fs-v1-multipart.go +++ b/fs-v1-multipart.go @@ -588,8 +588,13 @@ func (fs fsObjects) CompleteMultipartUpload(bucket string, object string, upload // Save additional metadata only if extended headers such as "X-Amz-Meta-" are set. if hasExtendedHeader(fsMeta.Meta) { fsMeta.Meta["md5Sum"] = s3MD5 + uniqueID := getUUID() + fsMetaTmp := path.Join(tmpMetaPrefix, uniqueID) + if err = writeFSMetadata(fs.storage, minioMetaBucket, fsMetaTmp, fsMeta); err != nil { + return "", toObjectErr(err, bucket, object) + } fsMetaPath := path.Join(bucketMetaPrefix, bucket, object, fsMetaJSONFile) - if err = writeFSMetadata(fs.storage, minioMetaBucket, fsMetaPath, fsMeta); err != nil { + if err = fs.storage.RenameFile(minioMetaBucket, fsMetaTmp, minioMetaBucket, fsMetaPath); err != nil { return "", toObjectErr(err, bucket, object) } }