summaryrefslogtreecommitdiffstats
path: root/routers/repo/editor.go
diff options
context:
space:
mode:
authorDuncan Ogilvie <mr.exodia.tpodt@gmail.com>2017-11-29 02:50:39 +0100
committerLunny Xiao <xiaolunwen@gmail.com>2017-11-29 09:50:39 +0800
commit551f3cbe420dcb72bcb784205451d5b01b811041 (patch)
tree612c505d8f46972a598e1ca118cba45c775f329d /routers/repo/editor.go
parent4035ab05fa2d2c8ec95d346fea91cab8211dab17 (diff)
downloadgitea-551f3cbe420dcb72bcb784205451d5b01b811041.tar.gz
gitea-551f3cbe420dcb72bcb784205451d5b01b811041.zip
Memory usage improvements (#3013)
* govendor update code.gitea.io/git Signed-off-by: Duncan Ogilvie <mr.exodia.tpodt@gmail.com> * Greatly improve memory usage Signed-off-by: Duncan Ogilvie <mr.exodia.tpodt@gmail.com>
Diffstat (limited to 'routers/repo/editor.go')
-rw-r--r--routers/repo/editor.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/routers/repo/editor.go b/routers/repo/editor.go
index a6cc922364..82b04a84d2 100644
--- a/routers/repo/editor.go
+++ b/routers/repo/editor.go
@@ -73,11 +73,16 @@ func editFile(ctx *context.Context, isNewFile bool) {
// No way to edit a directory online.
if entry.IsDir() {
- ctx.Handle(404, "", nil)
+ ctx.Handle(404, "entry.IsDir", nil)
return
}
blob := entry.Blob()
+ if blob.Size() >= setting.UI.MaxDisplayFileSize {
+ ctx.Handle(404, "blob.Size", err)
+ return
+ }
+
dataRc, err := blob.Data()
if err != nil {
ctx.Handle(404, "blob.Data", err)
@@ -93,7 +98,7 @@ func editFile(ctx *context.Context, isNewFile bool) {
// Only text file are editable online.
if !base.IsTextFile(buf) {
- ctx.Handle(404, "", nil)
+ ctx.Handle(404, "base.IsTextFile", nil)
return
}