Skip to content

Commit 3a5889c

Browse files
committed
fix error handling
1 parent dfe8978 commit 3a5889c

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

modules/lfs/http_client.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func (c *HTTPClient) performOperation(ctx context.Context, objects []Pointer, dc
150150

151151
// performSingleOperation performs an LFS upload or download operation on a single object
152152
func performSingleOperation(ctx context.Context, object *ObjectResponse, dc DownloadCallback, uc UploadCallback, transferAdapter TransferAdapter) error {
153-
// the response from an lfs batch api request for this specific object id contained an error
153+
// the response from a lfs batch api request for this specific object id contained an error
154154
if object.Error != nil {
155155
log.Trace("Error on object %v: %v", object.Pointer, object.Error)
156156

@@ -161,15 +161,12 @@ func performSingleOperation(ctx context.Context, object *ObjectResponse, dc Down
161161
}
162162
} else {
163163
// this was NOT an 'upload' request inside the batch request, meaning it must be a 'download' request
164-
err := dc(object.Pointer, nil, object.Error)
165-
if errors.Is(object.Error, ErrObjectNotExist) {
166-
log.Warn("Ignoring missing upstream LFS object %-v: %v", object.Pointer, err)
167-
return nil
164+
if err := dc(object.Pointer, nil, object.Error); err != nil {
165+
return err
168166
}
169-
170-
// this was a 'download' request which was a legitimate error response from the batch api (not an http/404)
171-
return err
172167
}
168+
// if the callback returns no err, then the error could be ignored, and the operations should continue
169+
return nil
173170
}
174171

175172
// the response from an lfs batch api request contained necessary upload/download fields to act upon

modules/repository/repo.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package repository
55

66
import (
77
"context"
8+
"errors"
89
"fmt"
910
"io"
1011
"strings"
@@ -180,6 +181,11 @@ func StoreMissingLfsObjectsInRepository(ctx context.Context, repo *repo_model.Re
180181

181182
downloadObjects := func(pointers []lfs.Pointer) error {
182183
err := lfsClient.Download(ctx, pointers, func(p lfs.Pointer, content io.ReadCloser, objectError error) error {
184+
if errors.Is(objectError, lfs.ErrObjectNotExist) {
185+
log.Warn("Ignoring missing upstream LFS object %-v: %v", p, objectError)
186+
return nil
187+
}
188+
183189
if objectError != nil {
184190
return objectError
185191
}

0 commit comments

Comments
 (0)