Fix deadlock in updateRepository (#1813)
This commit is contained in:
parent
0c332f0480
commit
9c66d1d9ea
1 changed files with 8 additions and 4 deletions
|
@ -619,18 +619,22 @@ func (repo *Repository) IsOwnedBy(userID int64) bool {
|
||||||
return repo.OwnerID == userID
|
return repo.OwnerID == userID
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateSize updates the repository size, calculating it using git.GetRepoSize
|
func (repo *Repository) updateSize(e Engine) error {
|
||||||
func (repo *Repository) UpdateSize() error {
|
|
||||||
repoInfoSize, err := git.GetRepoSize(repo.RepoPath())
|
repoInfoSize, err := git.GetRepoSize(repo.RepoPath())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("UpdateSize: %v", err)
|
return fmt.Errorf("UpdateSize: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
repo.Size = repoInfoSize.Size + repoInfoSize.SizePack
|
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
|
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.
|
// CanBeForked returns true if repository meets the requirements of being forked.
|
||||||
func (repo *Repository) CanBeForked() bool {
|
func (repo *Repository) CanBeForked() bool {
|
||||||
return !repo.IsBare
|
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)
|
log.Error(4, "Failed to update size for repository: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue