From ab1bb15e7335baace6bbc1b0d271c9dbdc8b8eee Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 25 Nov 2025 14:30:37 -0800 Subject: [PATCH] Update weed/s3api/s3api_bucket_handlers.go Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- weed/s3api/s3api_bucket_handlers.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/weed/s3api/s3api_bucket_handlers.go b/weed/s3api/s3api_bucket_handlers.go index f09b1af55..6300aa7ea 100644 --- a/weed/s3api/s3api_bucket_handlers.go +++ b/weed/s3api/s3api_bucket_handlers.go @@ -587,6 +587,11 @@ func (s3a *S3ApiServer) autoCreateBucket(r *http.Request, bucket string) error { } if err := s3a.mkdir(s3a.option.BucketsPath, bucket, fn); err != nil { + // In case of a race condition where another request created the bucket + // in the meantime, check for existence before returning an error. + if exist, _ := s3a.exists(s3a.option.BucketsPath, bucket, true); exist { + return nil + } return fmt.Errorf("failed to auto-create bucket %s: %w", bucket, err) }