1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-11-25 08:59:31 -05:00

Move add to hook queue for created repo to outside xorm session. (#7675)

Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
This commit is contained in:
David Svantesson 2019-07-31 08:13:04 +02:00 committed by Lauris BH
parent d974c139b4
commit 41336351b7

View file

@ -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)
@ -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 {
@ -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)
}