summaryrefslogtreecommitdiffstats
path: root/modules/context/repo.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-05-10 02:27:03 +0100
committerGitHub <noreply@github.com>2021-05-10 03:27:03 +0200
commit270aab429ef025df9a0b9bf9e3982729ae8df449 (patch)
tree215550ee5938876d4caf8516777d6f4bcaa91b40 /modules/context/repo.go
parent038e1db4dfc7a7fc0a8675f66f6be9a3dd5f10c2 (diff)
downloadgitea-270aab429ef025df9a0b9bf9e3982729ae8df449.tar.gz
gitea-270aab429ef025df9a0b9bf9e3982729ae8df449.zip
On open repository open common cat file batch and batch-check (#15667)
Use common git cat-file --batch and git cat-file --batch-check to significantly reduce calls to git. Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/context/repo.go')
-rw-r--r--modules/context/repo.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/modules/context/repo.go b/modules/context/repo.go
index c1f60a1362..3e48b34b3d 100644
--- a/modules/context/repo.go
+++ b/modules/context/repo.go
@@ -905,12 +905,18 @@ func (ctx *Context) IssueTemplatesFromDefaultBranch() []api.IssueTemplate {
log.Debug("DataAsync: %v", err)
continue
}
- defer r.Close()
+ closed := false
+ defer func() {
+ if !closed {
+ _ = r.Close()
+ }
+ }()
data, err := ioutil.ReadAll(r)
if err != nil {
log.Debug("ReadAll: %v", err)
continue
}
+ _ = r.Close()
var it api.IssueTemplate
content, err := markdown.ExtractMetadata(string(data), &it)
if err != nil {