Skip to content

Commit

Permalink
Move add to hook queue for created repo to outside xorm session. (#7675)
Browse files Browse the repository at this point in the history
Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
  • Loading branch information
davidsvantesson authored and lafriks committed Jul 31, 2019
1 parent d974c13 commit 4133635
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions models/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -1332,7 +1332,6 @@ func createRepository(e *xorm.Session, doer, u *User, repo *Repository) (err err
}); err != nil {
return fmt.Errorf("prepareWebhooks: %v", err)
}
go HookQueue.Add(repo.ID)
} else if err = repo.recalculateAccesses(e); err != nil {
// Organization automatically called this in addRepository method.
return fmt.Errorf("recalculateAccesses: %v", err)
Expand Down Expand Up @@ -1402,7 +1401,16 @@ func CreateRepository(doer, u *User, opts CreateRepoOptions) (_ *Repository, err
}
}

return repo, sess.Commit()
if err = sess.Commit(); err != nil {
return nil, err
}

// Add to hook queue for created repo after session commit.
if u.IsOrganization() {
go HookQueue.Add(repo.ID)
}

return repo, err
}

func countRepositories(userID int64, private bool) int64 {
Expand Down Expand Up @@ -2462,6 +2470,11 @@ func ForkRepository(doer, u *User, oldRepo *Repository, name, desc string) (_ *R
go HookQueue.Add(oldRepo.ID)
}

// Add to hook queue for created repo after session commit.
if u.IsOrganization() {
go HookQueue.Add(repo.ID)
}

if err = repo.UpdateSize(); err != nil {
log.Error("Failed to update size for repository: %v", err)
}
Expand Down

0 comments on commit 4133635

Please sign in to comment.