summaryrefslogtreecommitdiffstats
path: root/models/star.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2019-01-14 02:29:58 +0000
committertechknowlogick <hello@techknowlogick.com>2019-01-13 21:29:58 -0500
commit6868378673f5bb21eac54719d719557b32448db6 (patch)
tree561ad952fa24332823d1288b1ff364206f1e4caf /models/star.go
parent656456441ca09de27ffb44d7a8042db811ff989e (diff)
downloadgitea-6868378673f5bb21eac54719d719557b32448db6.tar.gz
gitea-6868378673f5bb21eac54719d719557b32448db6.zip
Ensure that sessions are passed into queries that could use the database to prevent deadlocks (#5718)
* Fixed deadlock in CreateComment * Fix possible deadlock in UpdateIssueDeadline from createDeadlineComment * Ensure that calls to IsTimeTracker enabled are called within session Signed-off-by: Andrew Thornton <art27@cantab.net> * Ensure that calls to reactionList are also called within session Signed-off-by: Andrew Thornton <art27@cantab.net> * Ensure all calls in NewPullRequest with the session are called within the session Signed-off-by: Andrew Thornton <art27@cantab.net> * Deal with potential deadlocks in repo Signed-off-by: Andrew Thornton <art27@cantab.net> * Ensure that isStaring is checked within our transaction Signed-off-by: Andrew Thornton <art27@cantab.net> * Fix mistake in isOrganizationMember Sorry.
Diffstat (limited to 'models/star.go')
-rw-r--r--models/star.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/models/star.go b/models/star.go
index 96f876ba0a..18d28b558a 100644
--- a/models/star.go
+++ b/models/star.go
@@ -21,7 +21,7 @@ func StarRepo(userID, repoID int64, star bool) error {
}
if star {
- if IsStaring(userID, repoID) {
+ if isStaring(sess, userID, repoID) {
return nil
}
@@ -35,7 +35,7 @@ func StarRepo(userID, repoID int64, star bool) error {
return err
}
} else {
- if !IsStaring(userID, repoID) {
+ if !isStaring(sess, userID, repoID) {
return nil
}
@@ -55,7 +55,11 @@ func StarRepo(userID, repoID int64, star bool) error {
// IsStaring checks if user has starred given repository.
func IsStaring(userID, repoID int64) bool {
- has, _ := x.Get(&Star{0, userID, repoID})
+ return isStaring(x, userID, repoID)
+}
+
+func isStaring(e Engine, userID, repoID int64) bool {
+ has, _ := e.Get(&Star{0, userID, repoID})
return has
}