fix(server): skip initing users if inited

This commit is contained in:
hexxa 2022-09-16 12:27:47 +08:00 committed by Hexxa
parent 4f6683de03
commit 61757aff4a
4 changed files with 37 additions and 22 deletions

View file

@ -170,6 +170,18 @@ func (h *MultiUsersSvc) Init(ctx context.Context, adminName string) (string, err
return "", fmt.Errorf("predefined user is invalid: %s", err)
}
for _, userCfg := range userCfgs {
_, err := h.deps.Users().GetUserByName(ctx, userCfg.Name)
if err != nil {
if errors.Is(err, db.ErrUserNotFound) {
// no op, need initing
} else {
return "", err
}
} else {
h.deps.Log().Warn("warning: users exists, skip initing(%s)", userCfg.Name)
continue
}
// TODO: following operations must be atomic
// TODO: check if the folders already exists
fsRootFolder := q.FsRootPath(userCfg.Name, "/")