summaryrefslogtreecommitdiffstats
path: root/routers/repo/lfs.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-04-20 06:25:08 +0800
committerGitHub <noreply@github.com>2021-04-19 18:25:08 -0400
commit9d99f6ab19ac3f97af3ca126720e9075c127a652 (patch)
treeb817b4582a871f83b91ad7977fe772fc3501c1e8 /routers/repo/lfs.go
parentc9cc6698d2172625854cd063301e63602204a2a1 (diff)
downloadgitea-9d99f6ab19ac3f97af3ca126720e9075c127a652.tar.gz
gitea-9d99f6ab19ac3f97af3ca126720e9075c127a652.zip
Refactor renders (#15175)
* Refactor renders * Some performance optimization * Fix comment * Transform reader * Fix csv test * Fix test * Fix tests * Improve optimaziation * Fix test * Fix test * Detect file encoding with reader * Improve optimaziation * reduce memory usage * improve code * fix build * Fix test * Fix for go1.15 * Fix render * Fix comment * Fix lint * Fix test * Don't use NormalEOF when unnecessary * revert change on util.go * Apply suggestions from code review Co-authored-by: zeripath <art27@cantab.net> * rename function * Take NormalEOF back Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'routers/repo/lfs.go')
-rw-r--r--routers/repo/lfs.go13
1 files changed, 3 insertions, 10 deletions
diff --git a/routers/repo/lfs.go b/routers/repo/lfs.go
index 457ffb6aba..3a7ce2e23b 100644
--- a/routers/repo/lfs.go
+++ b/routers/repo/lfs.go
@@ -296,20 +296,13 @@ func LFSFileGet(ctx *context.Context) {
break
}
- d, _ := ioutil.ReadAll(dataRc)
- buf = charset.ToUTF8WithFallback(append(buf, d...))
+ buf := charset.ToUTF8WithFallbackReader(io.MultiReader(bytes.NewReader(buf), dataRc))
// Building code view blocks with line number on server side.
- var fileContent string
- if content, err := charset.ToUTF8WithErr(buf); err != nil {
- log.Error("ToUTF8WithErr: %v", err)
- fileContent = string(buf)
- } else {
- fileContent = content
- }
+ fileContent, _ := ioutil.ReadAll(buf)
var output bytes.Buffer
- lines := strings.Split(fileContent, "\n")
+ lines := strings.Split(string(fileContent), "\n")
//Remove blank line at the end of file
if len(lines) > 0 && lines[len(lines)-1] == "" {
lines = lines[:len(lines)-1]