Przeglądaj źródła

Fix race condition in team functions (#3268)

tags/v1.4.0-rc1
Ethan Koenig 6 lat temu
rodzic
commit
c64924682e
1 zmienionych plików z 6 dodań i 5 usunięć
  1. 6
    5
      models/org_team.go

+ 6
- 5
models/org_team.go Wyświetl plik

@@ -102,11 +102,12 @@ func (t *Team) addRepository(e Engine, repo *Repository) (err error) {
return err
}

t.NumRepos++
if _, err = e.ID(t.ID).Cols("num_repos").Update(t); err != nil {
if _, err = e.Incr("num_repos").ID(t.ID).Update(new(Team)); err != nil {
return fmt.Errorf("update team: %v", err)
}

t.NumRepos++

if err = repo.recalculateTeamAccesses(e, 0); err != nil {
return fmt.Errorf("recalculateAccesses: %v", err)
}
@@ -488,8 +489,6 @@ func AddTeamMember(team *Team, userID int64) error {
}

// Get team and its repositories.
team.NumMembers++

if err := team.GetRepositories(); err != nil {
return err
}
@@ -506,10 +505,12 @@ func AddTeamMember(team *Team, userID int64) error {
TeamID: team.ID,
}); err != nil {
return err
} else if _, err := sess.ID(team.ID).Update(team); err != nil {
} else if _, err := sess.Incr("num_members").ID(team.ID).Update(new(Team)); err != nil {
return err
}

team.NumMembers++

// Give access to team repositories.
for _, repo := range team.Repos {
if err := repo.recalculateTeamAccesses(sess, 0); err != nil {

Ładowanie…
Anuluj
Zapisz