diff --git a/cmd/xl-v1-multipart.go b/cmd/xl-v1-multipart.go index 5a94251ad..5a4369d65 100644 --- a/cmd/xl-v1-multipart.go +++ b/cmd/xl-v1-multipart.go @@ -739,6 +739,11 @@ func (xl xlObjects) CompleteMultipartUpload(ctx context.Context, bucket string, } if xl.isObject(bucket, object) { + // Deny if WORM is enabled + if globalWORMEnabled { + return ObjectInfo{}, ObjectAlreadyExists{Bucket: bucket, Object: object} + } + // Rename if an object already exists to temporary location. newUniqueID := mustGetUUID() @@ -767,13 +772,6 @@ func (xl xlObjects) CompleteMultipartUpload(ctx context.Context, bucket string, } } - // Deny if WORM is enabled - if globalWORMEnabled { - if xl.isObject(bucket, object) { - return ObjectInfo{}, ObjectAlreadyExists{Bucket: bucket, Object: object} - } - } - // Rename the multipart object to final location. if _, err = renameObject(ctx, onlineDisks, minioMetaMultipartBucket, uploadIDPath, bucket, object, writeQuorum); err != nil { return oi, toObjectErr(err, bucket, object) diff --git a/cmd/xl-v1-object.go b/cmd/xl-v1-object.go index f1de5cf76..33a6e7cf1 100644 --- a/cmd/xl-v1-object.go +++ b/cmd/xl-v1-object.go @@ -788,6 +788,11 @@ func (xl xlObjects) putObject(ctx context.Context, bucket string, object string, } if xl.isObject(bucket, object) { + // Deny if WORM is enabled + if globalWORMEnabled { + return ObjectInfo{}, ObjectAlreadyExists{Bucket: bucket, Object: object} + } + // Rename if an object already exists to temporary location. newUniqueID := mustGetUUID() @@ -816,13 +821,6 @@ func (xl xlObjects) putObject(ctx context.Context, bucket string, object string, return ObjectInfo{}, toObjectErr(err, bucket, object) } - // Deny if WORM is enabled - if globalWORMEnabled { - if xl.isObject(bucket, object) { - return ObjectInfo{}, ObjectAlreadyExists{Bucket: bucket, Object: object} - } - } - // Rename the successfully written temporary object to final location. if _, err = renameObject(ctx, onlineDisks, minioMetaTmpBucket, tempObj, bucket, object, writeQuorum); err != nil { return ObjectInfo{}, toObjectErr(err, bucket, object)