@@ -6,7 +6,6 @@ package git
6
6
import (
7
7
"context"
8
8
"fmt"
9
- "path"
10
9
"strings"
11
10
"time"
12
11
@@ -17,6 +16,7 @@ import (
17
16
"code.gitea.io/gitea/models/unit"
18
17
user_model "code.gitea.io/gitea/models/user"
19
18
"code.gitea.io/gitea/modules/setting"
19
+ "code.gitea.io/gitea/modules/util"
20
20
)
21
21
22
22
// LFSLock represents a git lfs lock of repository.
@@ -34,11 +34,7 @@ func init() {
34
34
35
35
// BeforeInsert is invoked from XORM before inserting an object of this type.
36
36
func (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 )
42
38
}
43
39
44
40
// CreateLFSLock creates a new lock.
@@ -53,7 +49,7 @@ func CreateLFSLock(ctx context.Context, repo *repo_model.Repository, lock *LFSLo
53
49
return nil , err
54
50
}
55
51
56
- lock .Path = cleanPath (lock .Path )
52
+ lock .Path = util . CleanPath (lock .Path )
57
53
lock .RepoID = repo .ID
58
54
59
55
l , err := GetLFSLock (dbCtx , repo , lock .Path )
@@ -73,7 +69,7 @@ func CreateLFSLock(ctx context.Context, repo *repo_model.Repository, lock *LFSLo
73
69
74
70
// GetLFSLock returns release by given path.
75
71
func GetLFSLock (ctx context.Context , repo * repo_model.Repository , path string ) (* LFSLock , error ) {
76
- path = cleanPath (path )
72
+ path = util . CleanPath (path )
77
73
rel := & LFSLock {RepoID : repo .ID }
78
74
has , err := db .GetEngine (ctx ).Where ("lower(path) = ?" , strings .ToLower (path )).Get (rel )
79
75
if err != nil {
0 commit comments