aboutsummaryrefslogtreecommitdiffstats
path: root/routers
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 /routers
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 'routers')
-rw-r--r--routers/repo/download.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/routers/repo/download.go b/routers/repo/download.go
index 1eedec8cb1..dafa62d0d9 100644
--- a/routers/repo/download.go
+++ b/routers/repo/download.go
@@ -100,7 +100,11 @@ func ServeBlobOrLFS(ctx *context.Context, blob *git.Blob) error {
if err != nil {
return err
}
+ closed := false
defer func() {
+ if closed {
+ return
+ }
if err = dataRc.Close(); err != nil {
log.Error("ServeBlobOrLFS: Close: %v", err)
}
@@ -110,6 +114,10 @@ func ServeBlobOrLFS(ctx *context.Context, blob *git.Blob) error {
if pointer.IsValid() {
meta, _ := ctx.Repo.Repository.GetLFSMetaObjectByOid(pointer.Oid)
if meta == nil {
+ if err = dataRc.Close(); err != nil {
+ log.Error("ServeBlobOrLFS: Close: %v", err)
+ }
+ closed = true
return ServeBlob(ctx, blob)
}
if httpcache.HandleGenericETagCache(ctx.Req, ctx.Resp, `"`+pointer.Oid+`"`) {
@@ -126,6 +134,10 @@ func ServeBlobOrLFS(ctx *context.Context, blob *git.Blob) error {
}()
return ServeData(ctx, ctx.Repo.TreePath, meta.Size, lfsDataRc)
}
+ if err = dataRc.Close(); err != nil {
+ log.Error("ServeBlobOrLFS: Close: %v", err)
+ }
+ closed = true
return ServeBlob(ctx, blob)
}