summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorEthan Koenig <etk39@cornell.edu>2017-05-26 01:08:13 -0400
committerLunny Xiao <xiaolunwen@gmail.com>2017-05-26 13:08:13 +0800
commit9c66d1d9ea102b50baefdaf1617a42bb741a4c3a (patch)
tree70867b6afd20d5521abfca67eae2890cd506c699 /models
parent0c332f0480e9aa72454641afe53aebb3b9ab6e57 (diff)
downloadgitea-9c66d1d9ea102b50baefdaf1617a42bb741a4c3a.tar.gz
gitea-9c66d1d9ea102b50baefdaf1617a42bb741a4c3a.zip
Fix deadlock in updateRepository (#1813)
Diffstat (limited to 'models')
-rw-r--r--models/repo.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/models/repo.go b/models/repo.go
index c806e2f74d..ecfc296c98 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -619,18 +619,22 @@ func (repo *Repository) IsOwnedBy(userID int64) bool {
return repo.OwnerID == userID
}
-// UpdateSize updates the repository size, calculating it using git.GetRepoSize
-func (repo *Repository) UpdateSize() error {
+func (repo *Repository) updateSize(e Engine) error {
repoInfoSize, err := git.GetRepoSize(repo.RepoPath())
if err != nil {
return fmt.Errorf("UpdateSize: %v", err)
}
repo.Size = repoInfoSize.Size + repoInfoSize.SizePack
- _, err = x.ID(repo.ID).Cols("size").Update(repo)
+ _, err = e.Id(repo.ID).Cols("size").Update(repo)
return err
}
+// UpdateSize updates the repository size, calculating it using git.GetRepoSize
+func (repo *Repository) UpdateSize() error {
+ return repo.updateSize(x)
+}
+
// CanBeForked returns true if repository meets the requirements of being forked.
func (repo *Repository) CanBeForked() bool {
return !repo.IsBare
@@ -1554,7 +1558,7 @@ func updateRepository(e Engine, repo *Repository, visibilityChanged bool) (err e
}
}
- if err = repo.UpdateSize(); err != nil {
+ if err = repo.updateSize(e); err != nil {
log.Error(4, "Failed to update size for repository: %v", err)
}
}