1
+ // Package lfstransfer provides functionality for handling LFS (Large File Storage) transfers.
1
2
package lfstransfer
2
3
3
4
import (
@@ -17,6 +18,7 @@ import (
17
18
"gitlab.com/gitlab-org/gitlab-shell/v14/internal/gitlabnet"
18
19
)
19
20
21
+ // Client holds configuration, arguments, and authentication details for the client.
20
22
type Client struct {
21
23
config * config.Config
22
24
args * commandargs.Shell
@@ -25,13 +27,15 @@ type Client struct {
25
27
header string
26
28
}
27
29
30
+ // BatchAction represents an action for a batch operation with metadata.
28
31
type BatchAction struct {
29
32
Href string `json:"href"`
30
33
Header map [string ]string `json:"header,omitempty"`
31
34
ExpiresAt time.Time `json:"expires_at,omitempty"`
32
35
ExpiresIn int `json:"expires_in,omitempty"`
33
36
}
34
37
38
+ // BatchObject represents an object in a batch operation with its metadata and actions.
35
39
type BatchObject struct {
36
40
Oid string `json:"oid,omitempty"`
37
41
Size int64 `json:"size"`
@@ -50,6 +54,7 @@ type batchRequest struct {
50
54
HashAlgorithm string `json:"hash_algo,omitempty"`
51
55
}
52
56
57
+ // BatchResponse contains batch operation results and the hash algorithm used.
53
58
type BatchResponse struct {
54
59
Objects []* BatchObject `json:"objects"`
55
60
HashAlgorithm string `json:"hash_algo,omitempty"`
@@ -79,30 +84,36 @@ type listLocksVerifyRequest struct {
79
84
Ref * batchRef `json:"ref,omitempty"`
80
85
}
81
86
87
+ // LockOwner represents the owner of a lock.
82
88
type LockOwner struct {
83
89
Name string `json:"name"`
84
90
}
85
91
92
+ // Lock represents a lock with its ID, path, timestamp, and owner details.
86
93
type Lock struct {
87
94
ID string `json:"id"`
88
95
Path string `json:"path"`
89
96
LockedAt time.Time `json:"locked_at"`
90
97
Owner * LockOwner `json:"owner"`
91
98
}
92
99
100
+ // ListLocksResponse contains a list of locks and a cursor for pagination.
93
101
type ListLocksResponse struct {
94
102
Locks []* Lock `json:"locks,omitempty"`
95
103
NextCursor string `json:"next_cursor,omitempty"`
96
104
}
97
105
106
+ // ListLocksVerifyResponse provides lists of locks for "ours" and "theirs" with a cursor for pagination.
98
107
type ListLocksVerifyResponse struct {
99
108
Ours []* Lock `json:"ours,omitempty"`
100
109
Theirs []* Lock `json:"theirs,omitempty"`
101
110
NextCursor string `json:"next_cursor,omitempty"`
102
111
}
103
112
113
+ // ClientHeader specifies the content type for Git LFS JSON requests.
104
114
var ClientHeader = "application/vnd.git-lfs+json"
105
115
116
+ // NewClient creates a new Client instance using the provided configuration and credentials.
106
117
func NewClient (config * config.Config , args * commandargs.Shell , href string , auth string ) (* Client , error ) {
107
118
return & Client {config : config , args : args , href : href , auth : auth , header : ClientHeader }, nil
108
119
}
@@ -121,6 +132,7 @@ func newHTTPClient() *retryablehttp.Client {
121
132
return client
122
133
}
123
134
135
+ // Batch performs a batch operation on objects and returns the result.
124
136
func (c * Client ) Batch (operation string , reqObjects []* BatchObject , ref string , reqHashAlgo string ) (* BatchResponse , error ) {
125
137
// FIXME: This causes tests to fail
126
138
// if ref == "" {
@@ -211,6 +223,7 @@ func (c *Client) PutObject(_, href string, headers map[string]string, r io.Reade
211
223
return nil
212
224
}
213
225
226
+ // Lock acquires a lock for the specified path with an optional reference name.
214
227
func (c * Client ) Lock (path , refname string ) (* Lock , error ) {
215
228
var ref * batchRef
216
229
if refname != "" {
@@ -268,6 +281,7 @@ func (c *Client) Lock(path, refname string) (*Lock, error) {
268
281
}
269
282
}
270
283
284
+ // Unlock releases the lock with the given id, optionally forcing the unlock.
271
285
func (c * Client ) Unlock (id string , force bool , refname string ) (* Lock , error ) {
272
286
var ref * batchRef
273
287
if refname != "" {
@@ -318,6 +332,7 @@ func (c *Client) Unlock(id string, force bool, refname string) (*Lock, error) {
318
332
}
319
333
}
320
334
335
+ // ListLocksVerify retrieves locks for the given path and id, with optional pagination.
321
336
func (c * Client ) ListLocksVerify (path , id , cursor string , limit int , ref string ) (* ListLocksVerifyResponse , error ) {
322
337
url , err := url .Parse (c .href )
323
338
if err != nil {
0 commit comments