Vérifier existence de buckets avant de seed

Continue silencieusement si tout existe déjà
This commit is contained in:
Victor Lacasse-Beaudoin 2023-04-24 16:29:24 -04:00
parent 9bbeb4b7ee
commit 7accc596c7

View file

@ -181,6 +181,17 @@ func handleV1Seed(c echo.Context) error {
var new_buckets []string var new_buckets []string
for _, bucket := range documents_buckets { for _, bucket := range documents_buckets {
exists, err := client.BucketExists(context.Background(), bucket)
if err != nil {
return c.JSON(http.StatusInternalServerError, map[string]string{
"message": "Error during minio#BucketExists",
})
}
if exists {
continue
}
if err = client.MakeBucket(context.Background(), bucket, minio.MakeBucketOptions{}); err != nil { if err = client.MakeBucket(context.Background(), bucket, minio.MakeBucketOptions{}); err != nil {
return c.JSON(http.StatusInternalServerError, map[string]string{ return c.JSON(http.StatusInternalServerError, map[string]string{
"message": "Error during minio#MakeBucket", "message": "Error during minio#MakeBucket",