mirror of
https://github.com/go-gitea/gitea.git
synced 2025-11-04 19:24:28 +01: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.
|
// Only some file types are editable online as text.
|
||||||
ctx.Data["IsFileText"] = typesniffer.DetectContentType(buf).IsRepresentableAsText()
|
ctx.Data["IsFileText"] = typesniffer.DetectContentType(buf).IsRepresentableAsText()
|
||||||
|
|
||||||
|
if blob.Size() >= setting.UI.MaxDisplayFileSize {
|
||||||
|
ctx.Data["IsFileTooLarge"] = true
|
||||||
|
} else {
|
||||||
d, _ := io.ReadAll(dataRc)
|
d, _ := io.ReadAll(dataRc)
|
||||||
|
|
||||||
buf = append(buf, d...)
|
buf = append(buf, d...)
|
||||||
@ -173,6 +176,7 @@ func editFile(ctx *context.Context, isNewFile bool) {
|
|||||||
} else {
|
} else {
|
||||||
ctx.Data["FileContent"] = content
|
ctx.Data["FileContent"] = content
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Append filename from query, or empty string to allow username the new file.
|
// Append filename from query, or empty string to allow username the new file.
|
||||||
treeNames = append(treeNames, fileName)
|
treeNames = append(treeNames, fileName)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user