Ajouter autoseed pendant serverCmd #66
1 changed files with 7 additions and 22 deletions
|
@ -253,29 +253,14 @@ func handleV1Seed(c echo.Context) error {
|
|||
})
|
||||
}
|
||||
|
||||
var new_buckets []string
|
||||
|
||||
for _, bucket := range cfg.Server.Documents.Buckets {
|
||||
exists, err := mediaClient.MinioClient.BucketExists(context.Background(), bucket)
|
||||
if err != nil {
|
||||
return c.JSON(http.StatusInternalServerError, map[string]string{
|
||||
"message": "Error during minio#BucketExists",
|
||||
"error": err.Error(),
|
||||
})
|
||||
}
|
||||
|
||||
if exists {
|
||||
continue
|
||||
}
|
||||
|
||||
if err = mediaClient.MinioClient.MakeBucket(context.Background(), bucket, minio.MakeBucketOptions{}); err != nil {
|
||||
return c.JSON(http.StatusInternalServerError, map[string]string{
|
||||
"message": "Error during minio#MakeBucket",
|
||||
"error": err.Error(),
|
||||
})
|
||||
}
|
||||
new_buckets = append(new_buckets, bucket)
|
||||
new_buckets, err := mediaClient.Seed()
|
||||
if err != nil {
|
||||
return c.JSON(http.StatusInternalServerError, map[string]string{
|
||||
"message": "Error during mediaClient.Seed()",
|
||||
"error": err.Error(),
|
||||
})
|
||||
}
|
||||
|
||||
var message string
|
||||
if len(new_buckets) == 0 {
|
||||
message = "All buckets already exist"
|
||||
|
|
Loading…
Reference in a new issue