summaryrefslogtreecommitdiffstats
path: root/models/status.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2018-10-26 17:37:57 +0800
committerLauris BH <lauris@nix.lv>2018-10-26 12:37:57 +0300
commite7822473e90a668bb165ed2914dcb4eafc3c7ebd (patch)
treec1fef60bcc1f4a5209deccc7c46f37b25d6f848b /models/status.go
parentaeb5655c25053bdcd7eee94ea37df88468374162 (diff)
downloadgitea-e7822473e90a668bb165ed2914dcb4eafc3c7ebd.tar.gz
gitea-e7822473e90a668bb165ed2914dcb4eafc3c7ebd.zip
Fix race on updatesize (#5190)
* fix race on updatesize * fix more repoPath
Diffstat (limited to 'models/status.go')
-rw-r--r--models/status.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/models/status.go b/models/status.go
index 3146f8d303..91d011f7c5 100644
--- a/models/status.go
+++ b/models/status.go
@@ -197,14 +197,15 @@ func newCommitStatus(sess *xorm.Session, opts NewCommitStatusOptions) error {
return fmt.Errorf("newCommitStatus[nil, %s]: no repository specified", opts.SHA)
}
opts.CommitStatus.RepoID = opts.Repo.ID
+ repoPath := opts.Repo.repoPath(sess)
if opts.Creator == nil {
- return fmt.Errorf("newCommitStatus[%s, %s]: no user specified", opts.Repo.RepoPath(), opts.SHA)
+ return fmt.Errorf("newCommitStatus[%s, %s]: no user specified", repoPath, opts.SHA)
}
- gitRepo, err := git.OpenRepository(opts.Repo.RepoPath())
+ gitRepo, err := git.OpenRepository(repoPath)
if err != nil {
- return fmt.Errorf("OpenRepository[%s]: %v", opts.Repo.RepoPath(), err)
+ return fmt.Errorf("OpenRepository[%s]: %v", repoPath, err)
}
if _, err := gitRepo.GetCommit(opts.SHA); err != nil {
return fmt.Errorf("GetCommit[%s]: %v", opts.SHA, err)
@@ -219,19 +220,19 @@ func newCommitStatus(sess *xorm.Session, opts NewCommitStatusOptions) error {
has, err := sess.Desc("index").Limit(1).Get(lastCommitStatus)
if err != nil {
sess.Rollback()
- return fmt.Errorf("newCommitStatus[%s, %s]: %v", opts.Repo.RepoPath(), opts.SHA, err)
+ return fmt.Errorf("newCommitStatus[%s, %s]: %v", repoPath, opts.SHA, err)
}
if has {
- log.Debug("newCommitStatus[%s, %s]: found", opts.Repo.RepoPath(), opts.SHA)
+ log.Debug("newCommitStatus[%s, %s]: found", repoPath, opts.SHA)
nextIndex = lastCommitStatus.Index
}
opts.CommitStatus.Index = nextIndex + 1
- log.Debug("newCommitStatus[%s, %s]: %d", opts.Repo.RepoPath(), opts.SHA, opts.CommitStatus.Index)
+ log.Debug("newCommitStatus[%s, %s]: %d", repoPath, opts.SHA, opts.CommitStatus.Index)
// Insert new CommitStatus
if _, err = sess.Insert(opts.CommitStatus); err != nil {
sess.Rollback()
- return fmt.Errorf("newCommitStatus[%s, %s]: %v", opts.Repo.RepoPath(), opts.SHA, err)
+ return fmt.Errorf("newCommitStatus[%s, %s]: %v", repoPath, opts.SHA, err)
}
return nil