Fully re-submit batch requests on 401
When a batch request received a 401, the request was re-run without resetting the Body, causing the request to error and fall back to individual processing. This just reruns the Batch() function.
This commit is contained in:
parent
f57eb5e7c0
commit
931d0fb48e
@ -200,16 +200,21 @@ func Batch(objects []*objectResource, operation string) ([]*objectResource, *Wra
|
|||||||
tracerx.Printf("api: batch %d files", len(objects))
|
tracerx.Printf("api: batch %d files", len(objects))
|
||||||
res, objs, wErr := doApiBatchRequest(req, creds)
|
res, objs, wErr := doApiBatchRequest(req, creds)
|
||||||
if wErr != nil {
|
if wErr != nil {
|
||||||
if res != nil {
|
if res == nil {
|
||||||
switch res.StatusCode {
|
sendApiEvent(apiEventFail)
|
||||||
case 404, 410:
|
return nil, wErr
|
||||||
tracerx.Printf("api: batch not implemented: %d", res.StatusCode)
|
}
|
||||||
sendApiEvent(apiEventFail)
|
|
||||||
return nil, Error(newNotImplError())
|
switch res.StatusCode {
|
||||||
}
|
case 401:
|
||||||
|
Config.SetPrivateAccess()
|
||||||
|
tracerx.Printf("api: batch not authorized, submitting with auth")
|
||||||
|
return Batch(objects, operation)
|
||||||
|
case 404, 410:
|
||||||
|
tracerx.Printf("api: batch not implemented: %d", res.StatusCode)
|
||||||
|
sendApiEvent(apiEventFail)
|
||||||
|
return nil, Error(newNotImplError())
|
||||||
}
|
}
|
||||||
sendApiEvent(apiEventFail)
|
|
||||||
return nil, wErr
|
|
||||||
}
|
}
|
||||||
LogTransfer("lfs.api.batch", res)
|
LogTransfer("lfs.api.batch", res)
|
||||||
|
|
||||||
@ -446,11 +451,6 @@ func doApiBatchRequest(req *http.Request, creds Creds) (*http.Response, []*objec
|
|||||||
via := make([]*http.Request, 0, 4)
|
via := make([]*http.Request, 0, 4)
|
||||||
res, wErr := doApiRequestWithRedirects(req, creds, via)
|
res, wErr := doApiRequestWithRedirects(req, creds, via)
|
||||||
|
|
||||||
if res != nil && res.StatusCode == 401 {
|
|
||||||
Config.SetPrivateAccess()
|
|
||||||
res, wErr = doApiRequestWithRedirects(req, creds, via)
|
|
||||||
}
|
|
||||||
|
|
||||||
if wErr != nil {
|
if wErr != nil {
|
||||||
return res, nil, wErr
|
return res, nil, wErr
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user