From f53085691e57afc618a772efd8439c3eb9844dcc Mon Sep 17 00:00:00 2001 From: bytedream Date: Fri, 2 May 2025 23:42:39 +0200 Subject: [PATCH] Move lfs cannot edit context data --- routers/web/repo/view_file.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/routers/web/repo/view_file.go b/routers/web/repo/view_file.go index 009aa6b505..fb41c44db0 100644 --- a/routers/web/repo/view_file.go +++ b/routers/web/repo/view_file.go @@ -140,11 +140,6 @@ func prepareToRenderFile(ctx *context.Context, entry *git.TreeEntry) { ctx.Data["LFSLockHint"] = ctx.Tr("repo.editor.this_file_locked") } - // Assume file is not editable first. - if fInfo.isLFSFile { - ctx.Data["EditFileTooltip"] = ctx.Tr("repo.editor.cannot_edit_lfs_files") - } - // read all needed attributes which will be used later // there should be no performance different between reading 2 or 4 here attrsMap, err := attribute.CheckAttributes(ctx, ctx.Repo.GitRepo, ctx.Repo.CommitID, attribute.CheckAttributeOpts{ @@ -290,7 +285,9 @@ func prepareToRenderFile(ctx *context.Context, entry *git.TreeEntry) { } } - if !fInfo.isLFSFile { + if fInfo.isLFSFile { + ctx.Data["EditFileTooltip"] = ctx.Tr("repo.editor.cannot_edit_lfs_files") + } else { if ctx.Repo.CanEnableEditor(ctx, ctx.Doer) { if lfsLock != nil && lfsLock.OwnerID != ctx.Doer.ID { ctx.Data["CanEditFile"] = false