diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2021-10-24 23:12:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-24 22:12:43 +0100 |
commit | f99d50fc9f8baf406f32a491b214f8a13617d086 (patch) | |
tree | b3cd8a1304e522f111690e9f68130e663012bb16 /routers/web/repo/lfs.go | |
parent | 932780c2bbae09f052e2fcd1a0701966483496e8 (diff) | |
download | gitea-f99d50fc9f8baf406f32a491b214f8a13617d086.tar.gz gitea-f99d50fc9f8baf406f32a491b214f8a13617d086.zip |
Read expected buffer size (#17409)
* Read expected buffer size.
* Changed name.
Diffstat (limited to 'routers/web/repo/lfs.go')
-rw-r--r-- | routers/web/repo/lfs.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/routers/web/repo/lfs.go b/routers/web/repo/lfs.go index 271c638553..5e24cfa3c0 100644 --- a/routers/web/repo/lfs.go +++ b/routers/web/repo/lfs.go @@ -25,6 +25,7 @@ import ( "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/storage" "code.gitea.io/gitea/modules/typesniffer" + "code.gitea.io/gitea/modules/util" ) const ( @@ -271,7 +272,7 @@ func LFSFileGet(ctx *context.Context) { } defer dataRc.Close() buf := make([]byte, 1024) - n, err := dataRc.Read(buf) + n, err := util.ReadAtMost(dataRc, buf) if err != nil { ctx.ServerError("Data", err) return @@ -296,10 +297,10 @@ func LFSFileGet(ctx *context.Context) { break } - buf := charset.ToUTF8WithFallbackReader(io.MultiReader(bytes.NewReader(buf), dataRc)) + rd := charset.ToUTF8WithFallbackReader(io.MultiReader(bytes.NewReader(buf), dataRc)) // Building code view blocks with line number on server side. - fileContent, _ := io.ReadAll(buf) + fileContent, _ := io.ReadAll(rd) var output bytes.Buffer lines := strings.Split(string(fileContent), "\n") |