1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-04 09:37:19 +00:00

Add Close() method to gogitRepository (#8901) (#8956)

Backport #8901 

In investigating #7947 it has become clear that the storage component of go-git repositories needs closing.

This PR adds this Close function and adds the Close functions as necessary.

In TransferOwnership the ctx.Repo.GitRepo is closed if it is open to help prevent the risk of multiple open files.

Fixes #7947
This commit is contained in:
zeripath
2019-11-13 13:54:04 +00:00
committed by GitHub
parent 43fc99a7ed
commit 3497efac4a
72 changed files with 390 additions and 106 deletions

View File

@ -678,6 +678,7 @@ func GetDiffRangeWithWhitespaceBehavior(repoPath, beforeCommitID, afterCommitID
if err != nil {
return nil, err
}
defer gitRepo.Close()
commit, err := gitRepo.GetCommit(afterCommitID)
if err != nil {
@ -750,6 +751,7 @@ func GetRawDiffForFile(repoPath, startCommit, endCommit string, diffType RawDiff
if err != nil {
return fmt.Errorf("OpenRepository: %v", err)
}
defer repo.Close()
commit, err := repo.GetCommit(endCommit)
if err != nil {