fichier: check that we actually got a download token and retry if we didn't
This commit is contained in:
parent
5e91b93e59
commit
fb305b5976
1 changed files with 7 additions and 1 deletions
|
@ -87,6 +87,11 @@ func (f *Fs) readFileInfo(ctx context.Context, url string) (*File, error) {
|
||||||
return &file, err
|
return &file, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// maybe do some actual validation later if necessary
|
||||||
|
func validToken(token *GetTokenResponse) bool {
|
||||||
|
return token.Status == "OK"
|
||||||
|
}
|
||||||
|
|
||||||
func (f *Fs) getDownloadToken(ctx context.Context, url string) (*GetTokenResponse, error) {
|
func (f *Fs) getDownloadToken(ctx context.Context, url string) (*GetTokenResponse, error) {
|
||||||
request := DownloadRequest{
|
request := DownloadRequest{
|
||||||
URL: url,
|
URL: url,
|
||||||
|
@ -101,7 +106,8 @@ func (f *Fs) getDownloadToken(ctx context.Context, url string) (*GetTokenRespons
|
||||||
var token GetTokenResponse
|
var token GetTokenResponse
|
||||||
err := f.pacer.Call(func() (bool, error) {
|
err := f.pacer.Call(func() (bool, error) {
|
||||||
resp, err := f.rest.CallJSON(ctx, &opts, &request, &token)
|
resp, err := f.rest.CallJSON(ctx, &opts, &request, &token)
|
||||||
return shouldRetry(ctx, resp, err)
|
doretry, err := shouldRetry(ctx, resp, err)
|
||||||
|
return doretry || !validToken(&token), err
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "couldn't list files")
|
return nil, errors.Wrap(err, "couldn't list files")
|
||||||
|
|
Loading…
Add table
Reference in a new issue