Skip to content

Commit 9c66d1d

Browse files
ethantkoeniglunny
authored andcommitted
Fix deadlock in updateRepository (#1813)
1 parent 0c332f0 commit 9c66d1d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

models/repo.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -619,18 +619,22 @@ func (repo *Repository) IsOwnedBy(userID int64) bool {
619619
return repo.OwnerID == userID
620620
}
621621

622-
// UpdateSize updates the repository size, calculating it using git.GetRepoSize
623-
func (repo *Repository) UpdateSize() error {
622+
func (repo *Repository) updateSize(e Engine) error {
624623
repoInfoSize, err := git.GetRepoSize(repo.RepoPath())
625624
if err != nil {
626625
return fmt.Errorf("UpdateSize: %v", err)
627626
}
628627

629628
repo.Size = repoInfoSize.Size + repoInfoSize.SizePack
630-
_, err = x.ID(repo.ID).Cols("size").Update(repo)
629+
_, err = e.Id(repo.ID).Cols("size").Update(repo)
631630
return err
632631
}
633632

633+
// UpdateSize updates the repository size, calculating it using git.GetRepoSize
634+
func (repo *Repository) UpdateSize() error {
635+
return repo.updateSize(x)
636+
}
637+
634638
// CanBeForked returns true if repository meets the requirements of being forked.
635639
func (repo *Repository) CanBeForked() bool {
636640
return !repo.IsBare
@@ -1554,7 +1558,7 @@ func updateRepository(e Engine, repo *Repository, visibilityChanged bool) (err e
15541558
}
15551559
}
15561560

1557-
if err = repo.UpdateSize(); err != nil {
1561+
if err = repo.updateSize(e); err != nil {
15581562
log.Error(4, "Failed to update size for repository: %v", err)
15591563
}
15601564
}

0 commit comments

Comments
 (0)