summaryrefslogtreecommitdiffstats
path: root/services/migrations
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2023-07-22 22:14:27 +0800
committerGitHub <noreply@github.com>2023-07-22 22:14:27 +0800
commitb167f35113e643ccdb17a2dde55bdec5960b284b (patch)
tree99a6e53bf1a9d4c9199c19113650cc48a8c1fd0e /services/migrations
parentc42b71877edb4830b9573101d20853222d66fb3c (diff)
downloadgitea-b167f35113e643ccdb17a2dde55bdec5960b284b.tar.gz
gitea-b167f35113e643ccdb17a2dde55bdec5960b284b.zip
Add context parameter to some database functions (#26055)
To avoid deadlock problem, almost database related functions should be have ctx as the first parameter. This PR do a refactor for some of these functions.
Diffstat (limited to 'services/migrations')
-rw-r--r--services/migrations/gitea_uploader.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/services/migrations/gitea_uploader.go b/services/migrations/gitea_uploader.go
index ad4293184e..ee7fc57851 100644
--- a/services/migrations/gitea_uploader.go
+++ b/services/migrations/gitea_uploader.go
@@ -515,6 +515,7 @@ func (g *GiteaLocalUploader) CreateComments(comments ...*base.Comment) error {
// CreatePullRequests creates pull requests
func (g *GiteaLocalUploader) CreatePullRequests(prs ...*base.PullRequest) error {
gprs := make([]*issues_model.PullRequest, 0, len(prs))
+ ctx := db.DefaultContext
for _, pr := range prs {
gpr, err := g.newPullRequest(pr)
if err != nil {
@@ -527,12 +528,12 @@ func (g *GiteaLocalUploader) CreatePullRequests(prs ...*base.PullRequest) error
gprs = append(gprs, gpr)
}
- if err := models.InsertPullRequests(gprs...); err != nil {
+ if err := models.InsertPullRequests(ctx, gprs...); err != nil {
return err
}
for _, pr := range gprs {
g.issues[pr.Issue.Index] = pr.Issue
- pull.AddToTaskQueue(pr)
+ pull.AddToTaskQueue(ctx, pr)
}
return nil
}