Bläddra i källkod

Fix sqlite lock (#5176)

* fix sqlite lock

* fix sqlite lock on getUnitType
tags/v1.7.0-dev
Lunny Xiao 5 år sedan
förälder
incheckning
5f938c0c78
Inget konto är kopplat till bidragsgivarens mejladress
3 ändrade filer med 13 tillägg och 5 borttagningar
  1. 2
    2
      models/notification.go
  2. 5
    1
      models/org_team.go
  3. 6
    2
      models/repo.go

+ 2
- 2
models/notification.go Visa fil



for _, watch := range watches { for _, watch := range watches {
issue.Repo.Units = nil issue.Repo.Units = nil
if issue.IsPull && !issue.Repo.CheckUnitUser(watch.UserID, false, UnitTypePullRequests) {
if issue.IsPull && !issue.Repo.checkUnitUser(e, watch.UserID, false, UnitTypePullRequests) {
continue continue
} }
if !issue.IsPull && !issue.Repo.CheckUnitUser(watch.UserID, false, UnitTypeIssues) {
if !issue.IsPull && !issue.Repo.checkUnitUser(e, watch.UserID, false, UnitTypeIssues) {
continue continue
} }



+ 5
- 1
models/org_team.go Visa fil



// UnitEnabled returns if the team has the given unit type enabled // UnitEnabled returns if the team has the given unit type enabled
func (t *Team) UnitEnabled(tp UnitType) bool { func (t *Team) UnitEnabled(tp UnitType) bool {
if err := t.getUnits(x); err != nil {
return t.unitEnabled(x, tp)
}

func (t *Team) unitEnabled(e Engine, tp UnitType) bool {
if err := t.getUnits(e); err != nil {
log.Warn("Error loading repository (ID: %d) units: %s", t.ID, err.Error()) log.Warn("Error loading repository (ID: %d) units: %s", t.ID, err.Error())
} }



+ 6
- 2
models/repo.go Visa fil



// CheckUnitUser check whether user could visit the unit of this repository // CheckUnitUser check whether user could visit the unit of this repository
func (repo *Repository) CheckUnitUser(userID int64, isAdmin bool, unitType UnitType) bool { func (repo *Repository) CheckUnitUser(userID int64, isAdmin bool, unitType UnitType) bool {
if err := repo.getUnitsByUserID(x, userID, isAdmin); err != nil {
return repo.checkUnitUser(x, userID, isAdmin, unitType)
}

func (repo *Repository) checkUnitUser(e Engine, userID int64, isAdmin bool, unitType UnitType) bool {
if err := repo.getUnitsByUserID(e, userID, isAdmin); err != nil {
return false return false
} }


var newRepoUnits = make([]*RepoUnit, 0, len(repo.Units)) var newRepoUnits = make([]*RepoUnit, 0, len(repo.Units))
for _, u := range repo.Units { for _, u := range repo.Units {
for _, team := range teams { for _, team := range teams {
if team.UnitEnabled(u.Type) {
if team.unitEnabled(e, u.Type) {
newRepoUnits = append(newRepoUnits, u) newRepoUnits = append(newRepoUnits, u)
break break
} }

Laddar…
Avbryt
Spara