diff options
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/v1/repo/file.go | 14 |
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) } |