0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-12-22 04:44:15 +01:00

Fix deadlock in updateRepository (#1813)

This commit is contained in:
Ethan Koenig 2017-05-26 01:08:13 -04:00 committed by Lunny Xiao
parent 0c332f0480
commit 9c66d1d9ea

View file

@ -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)
}
}