Skip to content

Commit

Permalink
Fix deadlock in updateRepository (#1813)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethantkoenig authored and lunny committed May 26, 2017
1 parent 0c332f0 commit 9c66d1d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions models/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}
Expand Down

0 comments on commit 9c66d1d

Please sign in to comment.