diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2016-12-22 17:00:39 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-22 17:00:39 +0800 |
commit | 0c5c34d7ddaf31a6d8123dac36b221de61f5ff96 (patch) | |
tree | 0bfbab9ff4ad4717eab1b8ae60cad4401c421658 /models/issue.go | |
parent | 4c89a9c33c4c097836f5bfa79cc7e5adc142a2f0 (diff) | |
download | gitea-0c5c34d7ddaf31a6d8123dac36b221de61f5ff96.tar.gz gitea-0c5c34d7ddaf31a6d8123dac36b221de61f5ff96.zip |
UpdateIssueUsersByMentions was calling database write operations while (#443)
a transaction session was in progress. MailParticipants was failing
silently because of the SQLITE_LOCKED error. Make sure failures in
MailParticipants enter the log, and pass on the transaction context.
issue: let caller pass in database context, and use it
issue_comment: obtain database context to pass to UpdateIssueMentions
issue_comment: log any error from call to MailParticipants
issue_mail: pass on database context to UpdateIssueMentions
Diffstat (limited to 'models/issue.go')
-rw-r--r-- | models/issue.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/models/issue.go b/models/issue.go index 0e6c794055..13d27b22c6 100644 --- a/models/issue.go +++ b/models/issue.go @@ -1085,7 +1085,7 @@ func GetIssueUserPairsByMode(uid, rid int64, isClosed bool, page, filterMode int // UpdateIssueMentions extracts mentioned people from content and // updates issue-user relations for them. -func UpdateIssueMentions(issueID int64, mentions []string) error { +func UpdateIssueMentions(e Engine, issueID int64, mentions []string) error { if len(mentions) == 0 { return nil } @@ -1095,7 +1095,7 @@ func UpdateIssueMentions(issueID int64, mentions []string) error { } users := make([]*User, 0, len(mentions)) - if err := x.In("lower_name", mentions).Asc("lower_name").Find(&users); err != nil { + if err := e.In("lower_name", mentions).Asc("lower_name").Find(&users); err != nil { return fmt.Errorf("find mentioned users: %v", err) } @@ -1119,7 +1119,7 @@ func UpdateIssueMentions(issueID int64, mentions []string) error { ids = append(ids, memberIDs...) } - if err := UpdateIssueUsersByMentions(issueID, ids); err != nil { + if err := UpdateIssueUsersByMentions(e, issueID, ids); err != nil { return fmt.Errorf("UpdateIssueUsersByMentions: %v", err) } @@ -1361,22 +1361,22 @@ func UpdateIssueUserByRead(uid, issueID int64) error { } // UpdateIssueUsersByMentions updates issue-user pairs by mentioning. -func UpdateIssueUsersByMentions(issueID int64, uids []int64) error { +func UpdateIssueUsersByMentions(e Engine, issueID int64, uids []int64) error { for _, uid := range uids { iu := &IssueUser{ UID: uid, IssueID: issueID, } - has, err := x.Get(iu) + has, err := e.Get(iu) if err != nil { return err } iu.IsMentioned = true if has { - _, err = x.Id(iu.ID).AllCols().Update(iu) + _, err = e.Id(iu.ID).AllCols().Update(iu) } else { - _, err = x.Insert(iu) + _, err = e.Insert(iu) } if err != nil { return err |