Make user creation via environment variables idempotent

This commit is contained in:
Frédéric Guillot 2018-08-29 20:58:03 -07:00
parent 41ce0a3b80
commit 6137b401ee
1 changed files with 6 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import (
"fmt"
"os"
"miniflux.app/logger"
"miniflux.app/model"
"miniflux.app/storage"
)
@ -27,6 +28,11 @@ func createAdmin(store *storage.Storage) {
os.Exit(1)
}
if store.UserExists(user.Username) {
logger.Info(`User %q already exists, skipping creation`, user.Username)
return
}
if err := store.CreateUser(user); err != nil {
fmt.Println(err)
os.Exit(1)