|
|
|
@ -33,10 +33,11 @@ func NewMinioInterface() (Interface, error) {
|
|
|
|
|
}
|
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second*20)
|
|
|
|
|
defer cancel()
|
|
|
|
|
initBucket := func(ctx context.Context) error {
|
|
|
|
|
for _, bucket := range utils.Distinct([]string{conf.TempBucket, conf.DataBucket}) {
|
|
|
|
|
exists, err := client.BucketExists(ctx, bucket)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, fmt.Errorf("minio bucket %s exists %w", bucket, err)
|
|
|
|
|
return fmt.Errorf("minio bucket %s exists %w", bucket, err)
|
|
|
|
|
}
|
|
|
|
|
if exists {
|
|
|
|
|
continue
|
|
|
|
@ -46,9 +47,14 @@ func NewMinioInterface() (Interface, error) {
|
|
|
|
|
ObjectLocking: conf.IsDistributedMod,
|
|
|
|
|
}
|
|
|
|
|
if err := client.MakeBucket(ctx, bucket, opt); err != nil {
|
|
|
|
|
return nil, fmt.Errorf("minio make bucket %s %w", bucket, err)
|
|
|
|
|
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{
|
|
|
|
|
client: client,
|
|
|
|
|
tempBucket: conf.TempBucket,
|
|
|
|
|