summaryrefslogtreecommitdiffstats
path: root/routers/common/repo.go
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2021-10-24 23:12:43 +0200
committerGitHub <noreply@github.com>2021-10-24 22:12:43 +0100
commitf99d50fc9f8baf406f32a491b214f8a13617d086 (patch)
treeb3cd8a1304e522f111690e9f68130e663012bb16 /routers/common/repo.go
parent932780c2bbae09f052e2fcd1a0701966483496e8 (diff)
downloadgitea-f99d50fc9f8baf406f32a491b214f8a13617d086.tar.gz
gitea-f99d50fc9f8baf406f32a491b214f8a13617d086.zip
Read expected buffer size (#17409)
* Read expected buffer size. * Changed name.
Diffstat (limited to 'routers/common/repo.go')
-rw-r--r--routers/common/repo.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/routers/common/repo.go b/routers/common/repo.go
index af9170164e..b0e14b63f5 100644
--- a/routers/common/repo.go
+++ b/routers/common/repo.go
@@ -18,6 +18,7 @@ import (
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/typesniffer"
+ "code.gitea.io/gitea/modules/util"
)
// ServeBlob download a git.Blob
@@ -42,8 +43,8 @@ func ServeBlob(ctx *context.Context, blob *git.Blob) error {
// ServeData download file from io.Reader
func ServeData(ctx *context.Context, name string, size int64, reader io.Reader) error {
buf := make([]byte, 1024)
- n, err := reader.Read(buf)
- if err != nil && err != io.EOF {
+ n, err := util.ReadAtMost(reader, buf)
+ if err != nil {
return err
}
if n >= 0 {