Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update User.NumRepos atomically in createRepository #7493

Merged
merged 3 commits into from
Jul 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions models/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down