Skip to content

Commit 70e4352

Browse files
lunnysilverwind
authored andcommitted
Adjust minio new sequence, now it will check whether bucket exist first and then create one if it doesn't exist (go-gitea#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 go-gitea#25984 Co-authored-by: silverwind <[email protected]>
1 parent 2bdc38e commit 70e4352

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

modules/storage/minio.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,16 @@ func NewMinioStorage(ctx context.Context, cfg *setting.Storage) (ObjectStorage,
9090
return nil, convertMinioErr(err)
9191
}
9292

93-
if err := minioClient.MakeBucket(ctx, config.Bucket, minio.MakeBucketOptions{
94-
Region: config.Location,
95-
}); err != nil {
96-
// Check to see if we already own this bucket (which happens if you run this twice)
97-
exists, errBucketExists := minioClient.BucketExists(ctx, config.Bucket)
98-
if !exists || errBucketExists != nil {
93+
// Check to see if we already own this bucket
94+
exists, errBucketExists := minioClient.BucketExists(ctx, config.Bucket)
95+
if errBucketExists != nil {
96+
return nil, convertMinioErr(err)
97+
}
98+
99+
if !exists {
100+
if err := minioClient.MakeBucket(ctx, config.Bucket, minio.MakeBucketOptions{
101+
Region: config.Location,
102+
}); err != nil {
99103
return nil, convertMinioErr(err)
100104
}
101105
}

0 commit comments

Comments
 (0)