mailru: fix rare nil pointer panic

This commit is contained in:
Ivan Andreev 2019-09-12 23:07:25 +03:00 committed by Nick Craig-Wood
parent 3cff258577
commit 8fb44a822d

View File

@ -217,11 +217,11 @@ var retryErrorCodes = []int{
// deserve to be retried. It returns the err as a convenience. // deserve to be retried. It returns the err as a convenience.
// Retries password authorization (once) in a special case of access denied. // Retries password authorization (once) in a special case of access denied.
func shouldRetry(res *http.Response, err error, f *Fs, opts *rest.Opts) (bool, error) { func shouldRetry(res *http.Response, err error, f *Fs, opts *rest.Opts) (bool, error) {
if res.StatusCode == 403 && f.opt.Password != "" && !f.passFailed { if res != nil && res.StatusCode == 403 && f.opt.Password != "" && !f.passFailed {
reAuthErr := f.reAuthorize(opts, err) reAuthErr := f.reAuthorize(opts, err)
return reAuthErr == nil, err // return an original error return reAuthErr == nil, err // return an original error
} }
if f.quirks.retry400 && res.StatusCode == 400 { if res != nil && res.StatusCode == 400 && f.quirks.retry400 {
return true, err return true, err
} }
return fserrors.ShouldRetry(err) || fserrors.ShouldRetryHTTP(res, retryErrorCodes), err return fserrors.ShouldRetry(err) || fserrors.ShouldRetryHTTP(res, retryErrorCodes), err