summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-09-18 01:54:15 +0100
committerGitHub <noreply@github.com>2021-09-17 20:54:15 -0400
commit25533657f6a3edd2d12c8b8112d009559a136201 (patch)
treebdab2bd70e3fb4156728f2e81bfc5dfdc2a46c38 /routers
parent693bea9780be8c9ecc40bc751e6fafbeaea07743 (diff)
downloadgitea-25533657f6a3edd2d12c8b8112d009559a136201.tar.gz
gitea-25533657f6a3edd2d12c8b8112d009559a136201.zip
Add caller to cat-file batch calls (#17082)
Some people still appear to report unclosed cat-files. This PR simply adds the caller to the process descriptor for the CatFileBatch and CatFileBatchCheck calls. Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/repo/file.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/routers/api/v1/repo/file.go b/routers/api/v1/repo/file.go
index 2b14d1a93c..d9451b8090 100644
--- a/routers/api/v1/repo/file.go
+++ b/routers/api/v1/repo/file.go
@@ -119,13 +119,15 @@ func GetArchive(ctx *context.APIContext) {
// "$ref": "#/responses/notFound"
repoPath := models.RepoPath(ctx.Params(":username"), ctx.Params(":reponame"))
- gitRepo, err := git.OpenRepository(repoPath)
- if err != nil {
- ctx.Error(http.StatusInternalServerError, "OpenRepository", err)
- return
+ if ctx.Repo.GitRepo == nil {
+ gitRepo, err := git.OpenRepository(repoPath)
+ if err != nil {
+ ctx.Error(http.StatusInternalServerError, "OpenRepository", err)
+ return
+ }
+ ctx.Repo.GitRepo = gitRepo
+ defer gitRepo.Close()
}
- ctx.Repo.GitRepo = gitRepo
- defer gitRepo.Close()
repo.Download(ctx.Context)
}