From 349d5b159751da77181256b42ea5c3687c5d0625 Mon Sep 17 00:00:00 2001 From: bytedream Date: Mon, 5 May 2025 02:07:01 +0200 Subject: [PATCH] Do not show editor for locked lfs file by other user --- routers/web/repo/editor.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/routers/web/repo/editor.go b/routers/web/repo/editor.go index 8783b3850c..ee43037bd1 100644 --- a/routers/web/repo/editor.go +++ b/routers/web/repo/editor.go @@ -162,6 +162,18 @@ func editFile(ctx *context.Context, isNewFile bool) { defer dataRc.Close() + if fInfo.isLFSFile { + lfsLock, err := git_model.GetTreePathLock(ctx, ctx.Repo.Repository.ID, ctx.Repo.TreePath) + if err != nil { + ctx.ServerError("GetTreePathLock", err) + return + } + if lfsLock != nil && lfsLock.OwnerID != ctx.Doer.ID { + ctx.NotFound(nil) + return + } + } + ctx.Data["FileSize"] = blob.Size() // Only some file types are editable online as text.