mirror of
https://github.com/datarhei/core.git
synced 2025-12-24 13:07:56 +08:00
Fix check for existing bucket
This commit is contained in:
22
io/fs/s3.go
22
io/fs/s3.go
@@ -76,18 +76,20 @@ func NewS3Filesystem(config S3Config) (Filesystem, error) {
|
||||
ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(30*time.Second))
|
||||
defer cancel()
|
||||
|
||||
err = client.MakeBucket(ctx, fs.bucket, minio.MakeBucketOptions{Region: fs.region})
|
||||
if err != nil {
|
||||
exists, errBucketExists := client.BucketExists(ctx, fs.bucket)
|
||||
if errBucketExists != nil {
|
||||
return nil, err
|
||||
}
|
||||
exists, errBucketExists := client.BucketExists(ctx, fs.bucket)
|
||||
if errBucketExists != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if exists {
|
||||
fs.logger.Debug().Log("Bucket already exists")
|
||||
}
|
||||
if exists {
|
||||
fs.logger.Debug().Log("Bucket already exists")
|
||||
} else {
|
||||
fs.logger.Debug().Log("Bucket created")
|
||||
err = client.MakeBucket(ctx, fs.bucket, minio.MakeBucketOptions{Region: fs.region})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
fs.logger.Debug().Log("Bucket created")
|
||||
}
|
||||
}
|
||||
|
||||
fs.client = client
|
||||
|
||||
Reference in New Issue
Block a user