aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorDavid Svantesson <davidsvantesson@gmail.com>2019-07-31 08:13:04 +0200
committerLauris BH <lauris@nix.lv>2019-07-31 09:13:04 +0300
commit41336351b7b378290c20602c31c68fd7fb32dce4 (patch)
tree561abf4e21fbe5b634c47463762c52fd67c79cd1 /models
parentd974c139b4a87a86254b3e4660b131152923f083 (diff)
downloadgitea-41336351b7b378290c20602c31c68fd7fb32dce4.tar.gz
gitea-41336351b7b378290c20602c31c68fd7fb32dce4.zip
Move add to hook queue for created repo to outside xorm session. (#7675)
Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
Diffstat (limited to 'models')
-rw-r--r--models/repo.go17
1 files changed, 15 insertions, 2 deletions
diff --git a/models/repo.go b/models/repo.go
index 501a2c9120..fe296c1a11 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -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)
}