mirror of
https://github.com/go-gitea/gitea
synced 2024-12-22 16:44:26 +00:00
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>
This commit is contained in:
parent
c5888eb985
commit
a321a4c2fc
@ -90,12 +90,16 @@ func NewMinioStorage(ctx context.Context, cfg *setting.Storage) (ObjectStorage,
|
|||||||
return nil, convertMinioErr(err)
|
return nil, convertMinioErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := minioClient.MakeBucket(ctx, config.Bucket, minio.MakeBucketOptions{
|
// Check to see if we already own this bucket
|
||||||
Region: config.Location,
|
exists, errBucketExists := minioClient.BucketExists(ctx, config.Bucket)
|
||||||
}); err != nil {
|
if errBucketExists != nil {
|
||||||
// Check to see if we already own this bucket (which happens if you run this twice)
|
return nil, convertMinioErr(err)
|
||||||
exists, errBucketExists := minioClient.BucketExists(ctx, config.Bucket)
|
}
|
||||||
if !exists || errBucketExists != nil {
|
|
||||||
|
if !exists {
|
||||||
|
if err := minioClient.MakeBucket(ctx, config.Bucket, minio.MakeBucketOptions{
|
||||||
|
Region: config.Location,
|
||||||
|
}); err != nil {
|
||||||
return nil, convertMinioErr(err)
|
return nil, convertMinioErr(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user