@@ -34,12 +34,12 @@ type LFSMetaObject struct {
34
34
35
35
// LFSMetaObjectBasic represents basic LFS metadata.
36
36
type LFSMetaObjectBasic struct {
37
- Oid string `xorm:"UNIQUE(s) INDEX NOT NULL "`
38
- Size int64 `xorm:"NOT NULL "`
37
+ Oid string `json:"oid "`
38
+ Size int64 `json:"size "`
39
39
}
40
40
41
- // IsPointerFile will return a partially filled LFSMetaObject if the provided byte slice is a pointer file
42
- func IsPointerFile (buf * []byte ) * LFSMetaObject {
41
+ // IsPointerFileAndStored will return a partially filled LFSMetaObject if the provided byte slice is a pointer file and stored in contentStore
42
+ func IsPointerFileAndStored (buf * []byte ) * LFSMetaObject {
43
43
if ! setting .LFS .StartServer {
44
44
return nil
45
45
}
@@ -70,6 +70,32 @@ func IsPointerFile(buf *[]byte) *LFSMetaObject {
70
70
return meta
71
71
}
72
72
73
+ // IsPointerFile will return a partially filled LFSMetaObject if the provided byte slice is a pointer file
74
+ func IsPointerFile (buf * []byte ) * LFSMetaObjectBasic {
75
+ if ! setting .LFS .StartServer {
76
+ return nil
77
+ }
78
+
79
+ headString := string (* buf )
80
+ if ! strings .HasPrefix (headString , LFSMetaFileIdentifier ) {
81
+ return nil
82
+ }
83
+
84
+ splitLines := strings .Split (headString , "\n " )
85
+ if len (splitLines ) < 3 {
86
+ return nil
87
+ }
88
+
89
+ oid := strings .TrimPrefix (splitLines [1 ], LFSMetaFileOidPrefix )
90
+ size , err := strconv .ParseInt (strings .TrimPrefix (splitLines [2 ], "size " ), 10 , 64 )
91
+ if len (oid ) != 64 || err != nil {
92
+ return nil
93
+ }
94
+ meta := & LFSMetaObjectBasic {Oid : oid , Size : size }
95
+
96
+ return meta
97
+ }
98
+
73
99
// RelativePath returns the relative path of the lfs object
74
100
func (m * LFSMetaObject ) RelativePath () string {
75
101
if len (m .Oid ) < 5 {
0 commit comments