Utiliser MediaClient.Seed() dans handleV1Seed

This commit is contained in:
Victor Lacasse-Beaudoin 2023-07-04 20:35:35 -04:00
parent 03cef363cd
commit 046b14520b

View file

@ -253,29 +253,14 @@ func handleV1Seed(c echo.Context) error {
}) })
} }
var new_buckets []string new_buckets, err := mediaClient.Seed()
if err != nil {
for _, bucket := range cfg.Server.Documents.Buckets { return c.JSON(http.StatusInternalServerError, map[string]string{
exists, err := mediaClient.MinioClient.BucketExists(context.Background(), bucket) "message": "Error during mediaClient.Seed()",
if err != nil { "error": err.Error(),
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)
} }
var message string var message string
if len(new_buckets) == 0 { if len(new_buckets) == 0 {
message = "All buckets already exist" message = "All buckets already exist"