@@ -6,7 +6,6 @@ package git
66import (
77 "context"
88 "fmt"
9- "path"
109 "strings"
1110 "time"
1211
@@ -17,6 +16,7 @@ import (
1716 "code.gitea.io/gitea/models/unit"
1817 user_model "code.gitea.io/gitea/models/user"
1918 "code.gitea.io/gitea/modules/setting"
19+ "code.gitea.io/gitea/modules/util"
2020)
2121
2222// LFSLock represents a git lfs lock of repository.
@@ -34,11 +34,7 @@ func init() {
3434
3535// BeforeInsert is invoked from XORM before inserting an object of this type.
3636func (l * LFSLock ) BeforeInsert () {
37- l .Path = cleanPath (l .Path )
38- }
39-
40- func cleanPath (p string ) string {
41- return path .Clean ("/" + p )[1 :]
37+ l .Path = util .CleanPath (l .Path )
4238}
4339
4440// CreateLFSLock creates a new lock.
@@ -53,7 +49,7 @@ func CreateLFSLock(ctx context.Context, repo *repo_model.Repository, lock *LFSLo
5349 return nil , err
5450 }
5551
56- lock .Path = cleanPath (lock .Path )
52+ lock .Path = util . CleanPath (lock .Path )
5753 lock .RepoID = repo .ID
5854
5955 l , err := GetLFSLock (dbCtx , repo , lock .Path )
@@ -73,7 +69,7 @@ func CreateLFSLock(ctx context.Context, repo *repo_model.Repository, lock *LFSLo
7369
7470// GetLFSLock returns release by given path.
7571func GetLFSLock (ctx context.Context , repo * repo_model.Repository , path string ) (* LFSLock , error ) {
76- path = cleanPath (path )
72+ path = util . CleanPath (path )
7773 rel := & LFSLock {RepoID : repo .ID }
7874 has , err := db .GetEngine (ctx ).Where ("lower(path) = ?" , strings .ToLower (path )).Get (rel )
7975 if err != nil {
0 commit comments