mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-20 19:08:29 +02:00
Do not read file if it is too large
This commit is contained in:
parent
f53085691e
commit
7684e1720d
@ -164,6 +164,9 @@ func editFile(ctx *context.Context, isNewFile bool) {
|
||||
// Only some file types are editable online as text.
|
||||
ctx.Data["IsFileText"] = typesniffer.DetectContentType(buf).IsRepresentableAsText()
|
||||
|
||||
if blob.Size() >= setting.UI.MaxDisplayFileSize {
|
||||
ctx.Data["IsFileTooLarge"] = true
|
||||
} else {
|
||||
d, _ := io.ReadAll(dataRc)
|
||||
|
||||
buf = append(buf, d...)
|
||||
@ -173,6 +176,7 @@ func editFile(ctx *context.Context, isNewFile bool) {
|
||||
} else {
|
||||
ctx.Data["FileContent"] = content
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Append filename from query, or empty string to allow username the new file.
|
||||
treeNames = append(treeNames, fileName)
|
||||
|
Loading…
x
Reference in New Issue
Block a user