diff --git a/models/repo.go b/models/repo.go index fc5f81eb5cc94..c60488844c8ab 100644 --- a/models/repo.go +++ b/models/repo.go @@ -1306,13 +1306,17 @@ func createRepository(e *xorm.Session, doer, u *User, repo *Repository) (err err return err } - u.NumRepos++ // Remember visibility preference. u.LastRepoVisibility = repo.IsPrivate - if err = updateUser(e, u); err != nil { + if err = updateUserCols(e, u, "last_repo_visibility"); err != nil { return fmt.Errorf("updateUser: %v", err) } + if _, err = e.Incr("num_repos").ID(u.ID).Update(new(User)); err != nil { + return fmt.Errorf("increment user total_repos: %v", err) + } + u.NumRepos++ + // Give access to all members in owner team. if u.IsOrganization() { t, err := u.getOwnerTeam(e)