pull/463/head
withchao 1 year ago
parent 0642f97e12
commit 12dd42c60d

@ -33,21 +33,27 @@ func NewMinioInterface() (Interface, error) {
} }
ctx, cancel := context.WithTimeout(context.Background(), time.Second*20) ctx, cancel := context.WithTimeout(context.Background(), time.Second*20)
defer cancel() defer cancel()
for _, bucket := range utils.Distinct([]string{conf.TempBucket, conf.DataBucket}) { initBucket := func(ctx context.Context) error {
exists, err := client.BucketExists(ctx, bucket) for _, bucket := range utils.Distinct([]string{conf.TempBucket, conf.DataBucket}) {
if err != nil { exists, err := client.BucketExists(ctx, bucket)
return nil, fmt.Errorf("minio bucket %s exists %w", bucket, err) if err != nil {
} return fmt.Errorf("minio bucket %s exists %w", bucket, err)
if exists { }
continue if exists {
} continue
opt := minio.MakeBucketOptions{ }
Region: conf.Location, opt := minio.MakeBucketOptions{
ObjectLocking: conf.IsDistributedMod, Region: conf.Location,
} ObjectLocking: conf.IsDistributedMod,
if err := client.MakeBucket(ctx, bucket, opt); err != nil { }
return nil, fmt.Errorf("minio make bucket %s %w", bucket, err) if err := client.MakeBucket(ctx, bucket, opt); err != nil {
return fmt.Errorf("minio make bucket %s %w", bucket, err)
}
} }
return nil
}
if err := initBucket(ctx); err != nil {
fmt.Println("minio init error:", err)
} }
return &minioImpl{ return &minioImpl{
client: client, client: client,

Loading…
Cancel
Save