fix: Fixes #243, fixed the error case for CopyObject to copy the object into itself

This commit is contained in:
jonaustin09
2023-09-18 09:29:25 -07:00
committed by Ben McClelland
parent c53707d4ae
commit cb6b60324c
3 changed files with 27 additions and 0 deletions
+4
View File
@@ -1239,6 +1239,10 @@ func (p *Posix) CopyObject(ctx context.Context, input *s3.CopyObjectInput) (*s3.
dstBucket := *input.Bucket
dstObject := *input.Key
if fmt.Sprintf("%v/%v", srcBucket, srcObject) == fmt.Sprintf("%v/%v", dstBucket, dstObject) {
return &s3.CopyObjectOutput{}, s3err.GetAPIError(s3err.ErrInvalidCopyDest)
}
_, err := os.Stat(srcBucket)
if errors.Is(err, fs.ErrNotExist) {
return nil, s3err.GetAPIError(s3err.ErrNoSuchBucket)