diff --git a/cmd/erasure-sets.go b/cmd/erasure-sets.go index 04976f3df..4eebd7fc4 100644 --- a/cmd/erasure-sets.go +++ b/cmd/erasure-sets.go @@ -1047,11 +1047,13 @@ func (s *erasureSets) CopyObject(ctx context.Context, srcBucket, srcObject, dstB // Version ID is set for the destination and source == destination version ID. // perform an in-place update. if dstOpts.VersionID != "" && srcOpts.VersionID == dstOpts.VersionID { + srcInfo.Reader.Close() // We are not interested in the reader stream at this point close it. return srcSet.CopyObject(ctx, srcBucket, srcObject, dstBucket, dstObject, srcInfo, srcOpts, dstOpts) } // Destination is not versioned and source version ID is empty // perform an in-place update. if !dstOpts.Versioned && srcOpts.VersionID == "" { + srcInfo.Reader.Close() // We are not interested in the reader stream at this point close it. return srcSet.CopyObject(ctx, srcBucket, srcObject, dstBucket, dstObject, srcInfo, srcOpts, dstOpts) } // CopyObject optimization where we don't create an entire copy @@ -1060,6 +1062,7 @@ func (s *erasureSets) CopyObject(ctx context.Context, srcBucket, srcObject, dstB // that we actually create a new dataDir for legacy objects. if dstOpts.Versioned && srcOpts.VersionID != dstOpts.VersionID && !srcInfo.Legacy { srcInfo.versionOnly = true + srcInfo.Reader.Close() // We are not interested in the reader stream at this point close it. return srcSet.CopyObject(ctx, srcBucket, srcObject, dstBucket, dstObject, srcInfo, srcOpts, dstOpts) } } diff --git a/cmd/object-handlers.go b/cmd/object-handlers.go index 70f09a6a8..2245c2219 100644 --- a/cmd/object-handlers.go +++ b/cmd/object-handlers.go @@ -1433,10 +1433,6 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re srcInfo.metadataOnly = false } - if srcInfo.metadataOnly { - gr.Close() // We are not interested in the reader stream at this point close it. - } - // Check if x-amz-metadata-directive or x-amz-tagging-directive was not set to REPLACE and source, // destination are same objects. Apply this restriction also when // metadataOnly is true indicating that we are not overwriting the object.