summaryrefslogtreecommitdiffstats
path: root/routers/web/repo/blame.go
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2024-04-01 21:11:30 +0800
committerGitHub <noreply@github.com>2024-04-01 21:11:30 +0800
commit751997ad34fdd52b9f3956b14395560b059c9ac1 (patch)
treeed31804eaad6dd0d85593e7457da8974c7106b0f /routers/web/repo/blame.go
parenta008486f5c5acfe2d2acb009f41dc660ee8348eb (diff)
downloadgitea-751997ad34fdd52b9f3956b14395560b059c9ac1.tar.gz
gitea-751997ad34fdd52b9f3956b14395560b059c9ac1.zip
Refactor file view & render (#30227)
The old code is inconsistent and fragile, and the UI isn't right.
Diffstat (limited to 'routers/web/repo/blame.go')
-rw-r--r--routers/web/repo/blame.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/routers/web/repo/blame.go b/routers/web/repo/blame.go
index 935e6d78fc..1887e4d95d 100644
--- a/routers/web/repo/blame.go
+++ b/routers/web/repo/blame.go
@@ -16,6 +16,7 @@ import (
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/highlight"
"code.gitea.io/gitea/modules/log"
+ "code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/templates"
"code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/util"
@@ -87,9 +88,16 @@ func RefBlame(ctx *context.Context) {
ctx.Data["IsBlame"] = true
- ctx.Data["FileSize"] = blob.Size()
+ fileSize := blob.Size()
+ ctx.Data["FileSize"] = fileSize
ctx.Data["FileName"] = blob.Name()
+ if fileSize >= setting.UI.MaxDisplayFileSize {
+ ctx.Data["IsFileTooLarge"] = true
+ ctx.HTML(http.StatusOK, tplRepoHome)
+ return
+ }
+
ctx.Data["NumLines"], err = blob.GetBlobLineCount()
ctx.Data["NumLinesSet"] = true