CopyObject: fix read/write err on closed pipe (#15135)

Fixes: #15128
Regression from PR#14971
This commit is contained in:
Poorna
2022-06-21 19:20:11 -07:00
committed by GitHub
parent 1cfb03fb74
commit cb097e6b0a
2 changed files with 3 additions and 4 deletions

View File

@@ -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)
}
}