mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
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.
This commit is contained in:
@@ -776,7 +776,11 @@ func (repo *Repository) UpdateLocalCopyBranch(branch string) error {
|
||||
|
||||
// PatchPath returns corresponding patch file path of repository by given issue ID.
|
||||
func (repo *Repository) PatchPath(index int64) (string, error) {
|
||||
if err := repo.GetOwner(); err != nil {
|
||||
return repo.patchPath(x, index)
|
||||
}
|
||||
|
||||
func (repo *Repository) patchPath(e Engine, index int64) (string, error) {
|
||||
if err := repo.getOwner(e); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -785,7 +789,11 @@ func (repo *Repository) PatchPath(index int64) (string, error) {
|
||||
|
||||
// SavePatch saves patch data to corresponding location by given issue ID.
|
||||
func (repo *Repository) SavePatch(index int64, patch []byte) error {
|
||||
patchPath, err := repo.PatchPath(index)
|
||||
return repo.savePatch(x, index, patch)
|
||||
}
|
||||
|
||||
func (repo *Repository) savePatch(e Engine, index int64, patch []byte) error {
|
||||
patchPath, err := repo.patchPath(e, index)
|
||||
if err != nil {
|
||||
return fmt.Errorf("PatchPath: %v", err)
|
||||
}
|
||||
@@ -1479,7 +1487,7 @@ func TransferOwnership(doer *User, newOwnerName string, repo *Repository) error
|
||||
collaboration := &Collaboration{RepoID: repo.ID}
|
||||
for _, c := range collaborators {
|
||||
if c.ID != newOwner.ID {
|
||||
isMember, err := newOwner.IsOrgMember(c.ID)
|
||||
isMember, err := isOrganizationMember(sess, newOwner.ID, c.ID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("IsOrgMember: %v", err)
|
||||
} else if !isMember {
|
||||
@@ -1536,12 +1544,12 @@ func TransferOwnership(doer *User, newOwnerName string, repo *Repository) error
|
||||
if err = os.Rename(RepoPath(owner.Name, repo.Name), RepoPath(newOwner.Name, repo.Name)); err != nil {
|
||||
return fmt.Errorf("rename repository directory: %v", err)
|
||||
}
|
||||
RemoveAllWithNotice("Delete repository local copy", repo.LocalCopyPath())
|
||||
removeAllWithNotice(sess, "Delete repository local copy", repo.LocalCopyPath())
|
||||
|
||||
// Rename remote wiki repository to new path and delete local copy.
|
||||
wikiPath := WikiPath(owner.Name, repo.Name)
|
||||
if com.IsExist(wikiPath) {
|
||||
RemoveAllWithNotice("Delete repository wiki local copy", repo.LocalWikiPath())
|
||||
removeAllWithNotice(sess, "Delete repository wiki local copy", repo.LocalWikiPath())
|
||||
if err = os.Rename(wikiPath, WikiPath(newOwner.Name, repo.Name)); err != nil {
|
||||
return fmt.Errorf("rename repository wiki: %v", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user