diff --git a/tq/basic_download.go b/tq/basic_download.go index b77b3298..b29fb242 100644 --- a/tq/basic_download.go +++ b/tq/basic_download.go @@ -91,7 +91,9 @@ func (a *basicDownloadAdapter) download(t *Transfer, cb ProgressCallback, authOk rel, err := t.Actions.Get("download") if err != nil { return err - // return errors.New("Object not found on the server.") + } + if rel == nil { + return errors.New("Object not found on the server.") } req, err := a.newHTTPRequest("GET", rel) diff --git a/tq/basic_upload.go b/tq/basic_upload.go index 2f3225a2..c75c67bf 100644 --- a/tq/basic_upload.go +++ b/tq/basic_upload.go @@ -46,7 +46,9 @@ func (a *basicUploadAdapter) DoTransfer(ctx interface{}, t *Transfer, cb Progres rel, err := t.Actions.Get("upload") if err != nil { return err - // return fmt.Errorf("No upload action for this object.") + } + if rel == nil { + return errors.New("No upload action for this object.") } req, err := a.newHTTPRequest("PUT", rel) diff --git a/tq/custom.go b/tq/custom.go index 4d3a1a48..26063fd4 100644 --- a/tq/custom.go +++ b/tq/custom.go @@ -4,6 +4,7 @@ import ( "bufio" "bytes" "encoding/json" + "errors" "fmt" "io" "path/filepath" @@ -265,7 +266,9 @@ func (a *customAdapter) DoTransfer(ctx interface{}, t *Transfer, cb ProgressCall rel, err := t.Actions.Get(a.getOperationName()) if err != nil { return err - // return errors.New("Object not found on the server.") + } + if rel == nil { + return errors.New("Object not found on the server.") } var req *customAdapterTransferRequest if a.direction == Upload { diff --git a/tq/transfer.go b/tq/transfer.go index 462358b9..0dab132d 100644 --- a/tq/transfer.go +++ b/tq/transfer.go @@ -104,7 +104,7 @@ const ( func (as ActionSet) Get(rel string) (*Action, error) { a, ok := as[rel] if !ok { - return nil, &ActionMissingError{Rel: rel} + return nil, nil } if !a.ExpiresAt.IsZero() && a.ExpiresAt.Before(time.Now().Add(objectExpirationToTransfer)) { @@ -124,14 +124,6 @@ func (e ActionExpiredErr) Error() string { e.Rel, e.At.In(time.Local).Format(time.RFC822)) } -type ActionMissingError struct { - Rel string -} - -func (e ActionMissingError) Error() string { - return fmt.Sprintf("tq: unable to find action %q", e.Rel) -} - func IsActionExpiredError(err error) bool { if _, ok := err.(*ActionExpiredErr); ok { return true @@ -139,13 +131,6 @@ func IsActionExpiredError(err error) bool { return false } -func IsActionMissingError(err error) bool { - if _, ok := err.(*ActionMissingError); ok { - return true - } - return false -} - // NewAdapterFunc creates new instances of Adapter. Code that wishes // to provide new Adapter instances should pass an implementation of this // function to RegisterNewTransferAdapterFunc() on a *Manifest. diff --git a/tq/transfer_queue.go b/tq/transfer_queue.go index 0fe0d673..e53a36a1 100644 --- a/tq/transfer_queue.go +++ b/tq/transfer_queue.go @@ -335,7 +335,7 @@ func (q *TransferQueue) enqueueAndCollectRetriesFor(batch batch) (batch, error) } else { tr := newTransfer(o, t.Name, t.Path) - if _, err := tr.Actions.Get(q.direction.String()); err != nil { + if a, err := tr.Actions.Get(q.direction.String()); err != nil { // XXX(taylor): duplication if q.canRetryObject(tr.Oid, err) { q.rc.Increment(tr.Oid) @@ -344,14 +344,14 @@ func (q *TransferQueue) enqueueAndCollectRetriesFor(batch batch) (batch, error) tracerx.Printf("tq: enqueue retry #%d for %q (size: %d)", count, tr.Oid, tr.Size) next = append(next, t) } else { - if !IsActionMissingError(err) { - q.errorc <- errors.Errorf("[%v] %v", tr.Name, err) - } + q.errorc <- errors.Errorf("[%v] %v", tr.Name, err) q.Skip(o.Size) q.wait.Done() } - + } else if a == nil { + q.Skip(o.Size) + q.wait.Done() } else { q.meter.StartTransfer(t.Name) toTransfer = append(toTransfer, tr) diff --git a/tq/tus_upload.go b/tq/tus_upload.go index 75317a39..aaf9aa30 100644 --- a/tq/tus_upload.go +++ b/tq/tus_upload.go @@ -39,7 +39,9 @@ func (a *tusUploadAdapter) DoTransfer(ctx interface{}, t *Transfer, cb ProgressC rel, err := t.Actions.Get("upload") if err != nil { return err - // return fmt.Errorf("No upload action for this object.") + } + if rel == nil { + return errors.New("No upload action for this object.") } // Note not supporting the Creation extension since the batch API generates URLs diff --git a/tq/verify.go b/tq/verify.go index fc28442a..68d2b9f0 100644 --- a/tq/verify.go +++ b/tq/verify.go @@ -16,11 +16,11 @@ const ( func verifyUpload(c *lfsapi.Client, t *Transfer) error { action, err := t.Actions.Get("verify") if err != nil { - if IsActionMissingError(err) { - return nil - } return err } + if action == nil { + return nil + } req, err := http.NewRequest("POST", action.Href, nil) if err != nil {