Skip to content

Commit 7262a29

Browse files
committed
Update
1 parent 7d40a36 commit 7262a29

File tree

5 files changed

+11
-17
lines changed

5 files changed

+11
-17
lines changed

modules/lfs/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type UploadCallback func(p Pointer, objectError error) (io.ReadCloser, error)
1919
// Client is used to communicate with a LFS source
2020
type Client interface {
2121
BatchSize() int
22-
Download(ctx context.Context, refName string, objects []Pointer, callback DownloadCallback) error
22+
Download(ctx context.Context, objects []Pointer, callback DownloadCallback) error
2323
Upload(ctx context.Context, objects []Pointer, callback UploadCallback) error
2424
}
2525

modules/lfs/filesystem_client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (c *FilesystemClient) objectPath(oid string) string {
3434
}
3535

3636
// Download reads the specific LFS object from the target path
37-
func (c *FilesystemClient) Download(ctx context.Context, refName string, objects []Pointer, callback DownloadCallback) error {
37+
func (c *FilesystemClient) Download(ctx context.Context, objects []Pointer, callback DownloadCallback) error {
3838
for _, object := range objects {
3939
p := Pointer{object.Oid, object.Size}
4040

modules/lfs/http_client.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ func (c *HTTPClient) transferNames() []string {
6767
return keys
6868
}
6969

70-
func (c *HTTPClient) batch(ctx context.Context, operation, refName string, objects []Pointer) (*BatchResponse, error) {
70+
func (c *HTTPClient) batch(ctx context.Context, operation string, objects []Pointer) (*BatchResponse, error) {
7171
log.Trace("BATCH operation with objects: %v", objects)
7272

7373
url := fmt.Sprintf("%s/objects/batch", c.endpoint)
7474

75-
request := &BatchRequest{operation, c.transferNames(), &Reference{Name: refName}, objects}
75+
request := &BatchRequest{operation, c.transferNames(), &Reference{}, objects}
7676
payload := new(bytes.Buffer)
7777
err := json.NewEncoder(payload).Encode(request)
7878
if err != nil {
@@ -106,17 +106,17 @@ func (c *HTTPClient) batch(ctx context.Context, operation, refName string, objec
106106
}
107107

108108
// Download reads the specific LFS object from the LFS server
109-
func (c *HTTPClient) Download(ctx context.Context, refName string, objects []Pointer, callback DownloadCallback) error {
110-
return c.performOperation(ctx, refName, objects, callback, nil)
109+
func (c *HTTPClient) Download(ctx context.Context, objects []Pointer, callback DownloadCallback) error {
110+
return c.performOperation(ctx, objects, callback, nil)
111111
}
112112

113113
// Upload sends the specific LFS object to the LFS server
114114
func (c *HTTPClient) Upload(ctx context.Context, objects []Pointer, callback UploadCallback) error {
115-
return c.performOperation(ctx, "", objects, nil, callback)
115+
return c.performOperation(ctx, objects, nil, callback)
116116
}
117117

118118
// performOperation takes a slice of LFS object pointers, batches them, and performs the upload/download operations concurrently in each batch
119-
func (c *HTTPClient) performOperation(ctx context.Context, refName string, objects []Pointer, dc DownloadCallback, uc UploadCallback) error {
119+
func (c *HTTPClient) performOperation(ctx context.Context, objects []Pointer, dc DownloadCallback, uc UploadCallback) error {
120120
if len(objects) == 0 {
121121
return nil
122122
}
@@ -126,7 +126,7 @@ func (c *HTTPClient) performOperation(ctx context.Context, refName string, objec
126126
operation = "upload"
127127
}
128128

129-
result, err := c.batch(ctx, operation, refName, objects)
129+
result, err := c.batch(ctx, operation, objects)
130130
if err != nil {
131131
return err
132132
}

modules/lfs/http_client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ func TestHTTPClientDownload(t *testing.T) {
248248
},
249249
}
250250

251-
err := client.Download(context.Background(), "", []Pointer{p}, func(p Pointer, content io.ReadCloser, objectError error) error {
251+
err := client.Download(context.Background(), []Pointer{p}, func(p Pointer, content io.ReadCloser, objectError error) error {
252252
if objectError != nil {
253253
return objectError
254254
}

modules/repository/repo.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,8 @@ func StoreMissingLfsObjectsInRepository(ctx context.Context, repo *repo_model.Re
179179
errChan := make(chan error, 1)
180180
go lfs.SearchPointerBlobs(ctx, gitRepo, pointerChan, errChan)
181181

182-
defaultBranch, err := gitrepo.GetDefaultBranch(ctx, repo)
183-
if err != nil {
184-
log.Error("Repo[%-v]: get default branch err: %v", repo, err)
185-
return err
186-
}
187-
188182
downloadObjects := func(pointers []lfs.Pointer) error {
189-
err := lfsClient.Download(ctx, git.RefNameFromBranch(defaultBranch).String(), pointers, func(p lfs.Pointer, content io.ReadCloser, objectError error) error {
183+
err := lfsClient.Download(ctx, pointers, func(p lfs.Pointer, content io.ReadCloser, objectError error) error {
190184
if errors.Is(objectError, lfs.ErrObjectNotExist) {
191185
log.Warn("Ignoring missing upstream LFS object %-v: %v", p, objectError)
192186
return nil

0 commit comments

Comments
 (0)