From 42b7c8728882a443b8e21cc77eb525d7ffbf351c Mon Sep 17 00:00:00 2001 From: bytedream Date: Fri, 9 May 2025 14:03:17 +0200 Subject: [PATCH] Get file size from fInfo --- routers/web/repo/editor.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/routers/web/repo/editor.go b/routers/web/repo/editor.go index b819a96819..62de825e52 100644 --- a/routers/web/repo/editor.go +++ b/routers/web/repo/editor.go @@ -170,16 +170,16 @@ func editFile(ctx *context.Context, isNewFile bool) { } } - ctx.Data["FileSize"] = blob.Size() + ctx.Data["FileSize"] = fInfo.fileSize // Only some file types are editable online as text. - ctx.Data["IsFileEditable"] = fInfo.st.IsRepresentableAsText() && !fInfo.isLFSFile && blob.Size() < setting.UI.MaxDisplayFileSize + ctx.Data["IsFileEditable"] = fInfo.st.IsRepresentableAsText() && !fInfo.isLFSFile && fInfo.fileSize < setting.UI.MaxDisplayFileSize if fInfo.isLFSFile { ctx.Data["NotEditableReason"] = ctx.Tr("repo.editor.cannot_edit_lfs_files") } else if !fInfo.st.IsRepresentableAsText() { ctx.Data["NotEditableReason"] = ctx.Tr("repo.editor.cannot_edit_non_text_files") - } else if blob.Size() >= setting.UI.MaxDisplayFileSize { + } else if fInfo.fileSize >= setting.UI.MaxDisplayFileSize { ctx.Data["NotEditableReason"] = ctx.Tr("repo.editor.cannot_edit_too_large_file") } else { d, _ := io.ReadAll(dataRc)