diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2023-08-12 16:03:54 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-12 08:03:54 +0000 |
commit | a321a4c2fce9eb6c72f4dda0ee9928e56e9ec223 (patch) | |
tree | e19eb5267f28dc1ec2e9aa26cd196520921aca9b /modules/storage | |
parent | c5888eb9854f5a04d5e796f2a53c64c9fc4c0cba (diff) | |
download | gitea-a321a4c2fce9eb6c72f4dda0ee9928e56e9ec223.tar.gz gitea-a321a4c2fce9eb6c72f4dda0ee9928e56e9ec223.zip |
Adjust minio new sequence, now it will check whether bucket exist first and then create one if it doesn't exist (#26420)
For some reason, the permission of the client_id and secret may cannot
create bucket, so now we will check whether bucket does exist first and
then try to create a bucket if it doesn't exist.
Try to fix #25984
Co-authored-by: silverwind <me@silverwind.io>
Diffstat (limited to 'modules/storage')
-rw-r--r-- | modules/storage/minio.go | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/modules/storage/minio.go b/modules/storage/minio.go index e7c315ae44..f50f341022 100644 --- a/modules/storage/minio.go +++ b/modules/storage/minio.go @@ -90,12 +90,16 @@ func NewMinioStorage(ctx context.Context, cfg *setting.Storage) (ObjectStorage, return nil, convertMinioErr(err) } - if err := minioClient.MakeBucket(ctx, config.Bucket, minio.MakeBucketOptions{ - Region: config.Location, - }); err != nil { - // Check to see if we already own this bucket (which happens if you run this twice) - exists, errBucketExists := minioClient.BucketExists(ctx, config.Bucket) - if !exists || errBucketExists != nil { + // Check to see if we already own this bucket + exists, errBucketExists := minioClient.BucketExists(ctx, config.Bucket) + if errBucketExists != nil { + return nil, convertMinioErr(err) + } + + if !exists { + if err := minioClient.MakeBucket(ctx, config.Bucket, minio.MakeBucketOptions{ + Region: config.Location, + }); err != nil { return nil, convertMinioErr(err) } } |