Skip to content

Commit f78c796

Browse files
authored
Merge branch 'main' into lunny/fix_api_pull_files
2 parents 43d92f9 + 180aa00 commit f78c796

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

routers/web/repo/editor.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"code.gitea.io/gitea/modules/markup"
2121
"code.gitea.io/gitea/modules/setting"
2222
"code.gitea.io/gitea/modules/templates"
23-
"code.gitea.io/gitea/modules/typesniffer"
2423
"code.gitea.io/gitea/modules/util"
2524
"code.gitea.io/gitea/modules/web"
2625
"code.gitea.io/gitea/routers/utils"
@@ -151,22 +150,22 @@ func editFile(ctx *context.Context, isNewFile bool) {
151150
return
152151
}
153152

154-
dataRc, err := blob.DataAsync()
153+
buf, dataRc, fInfo, err := getFileReader(ctx, ctx.Repo.Repository.ID, blob)
155154
if err != nil {
156-
ctx.NotFound(err)
155+
if git.IsErrNotExist(err) {
156+
ctx.NotFound(err)
157+
} else {
158+
ctx.ServerError("getFileReader", err)
159+
}
157160
return
158161
}
159162

160163
defer dataRc.Close()
161164

162165
ctx.Data["FileSize"] = blob.Size()
163166

164-
buf := make([]byte, 1024)
165-
n, _ := util.ReadAtMost(dataRc, buf)
166-
buf = buf[:n]
167-
168167
// Only some file types are editable online as text.
169-
if !typesniffer.DetectContentType(buf).IsRepresentableAsText() {
168+
if !fInfo.isTextFile || fInfo.isLFSFile {
170169
ctx.NotFound(nil)
171170
return
172171
}

0 commit comments

Comments
 (0)