From d7cc0498e012dd5a1d641d80187b1f4241bf56e3 Mon Sep 17 00:00:00 2001 From: "ruitao.liu" Date: Thu, 12 Nov 2020 14:11:03 +0800 Subject: [PATCH] check if bucket already exists. --- weed/s3api/s3api_bucket_handlers.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/weed/s3api/s3api_bucket_handlers.go b/weed/s3api/s3api_bucket_handlers.go index b4f83a87f..bd3d7fd58 100644 --- a/weed/s3api/s3api_bucket_handlers.go +++ b/weed/s3api/s3api_bucket_handlers.go @@ -89,6 +89,9 @@ func (s3a *S3ApiServer) PutBucketHandler(w http.ResponseWriter, r *http.Request) writeErrorResponse(w, s3err.ErrInternalError, r.URL) return } + if exist, err := s3a.exists(s3a.option.BucketsPath, bucket, true); err == nil && exist { + errCode = s3err.ErrBucketAlreadyExists + } if errCode != s3err.ErrNone { writeErrorResponse(w, errCode, r.URL) return