mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-11-28 04:36:11 +01:00
Backport #26420 by @lunny 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: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
parent
9112ce22a4
commit
2d1202b32c
|
@ -90,12 +90,16 @@ func NewMinioStorage(ctx context.Context, cfg *setting.Storage) (ObjectStorage,
|
||||||
return nil, convertMinioErr(err)
|
return nil, convertMinioErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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{
|
if err := minioClient.MakeBucket(ctx, config.Bucket, minio.MakeBucketOptions{
|
||||||
Region: config.Location,
|
Region: config.Location,
|
||||||
}); err != nil {
|
}); 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 {
|
|
||||||
return nil, convertMinioErr(err)
|
return nil, convertMinioErr(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue