From fb305b5976b98e5ac24abb97426fb3ff273c4d60 Mon Sep 17 00:00:00 2001 From: buengese Date: Mon, 5 Jul 2021 20:55:08 +0200 Subject: [PATCH] fichier: check that we actually got a download token and retry if we didn't --- backend/fichier/api.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/fichier/api.go b/backend/fichier/api.go index a2143bd31..54d4b2cd5 100644 --- a/backend/fichier/api.go +++ b/backend/fichier/api.go @@ -87,6 +87,11 @@ func (f *Fs) readFileInfo(ctx context.Context, url string) (*File, error) { 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) { request := DownloadRequest{ URL: url, @@ -101,7 +106,8 @@ func (f *Fs) getDownloadToken(ctx context.Context, url string) (*GetTokenRespons var token GetTokenResponse err := f.pacer.Call(func() (bool, error) { 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 { return nil, errors.Wrap(err, "couldn't list files")