mirror of
https://github.com/rclone/rclone.git
synced 2024-11-26 18:31:17 +08:00
acd: Fix panic on token expiry - fixes #1117
This commit is contained in:
parent
50e190ff54
commit
40c02989f1
|
@ -95,7 +95,6 @@ type Fs struct {
|
|||
root string // the path we are working on
|
||||
dirCache *dircache.DirCache // Map of directory path to directory id
|
||||
pacer *pacer.Pacer // pacer for API calls
|
||||
ts *oauthutil.TokenSource // token source for oauth
|
||||
trueRootID string // ID of true root directory
|
||||
tokenRenewer *oauthutil.Renew // renew the token on expiry
|
||||
}
|
||||
|
@ -157,8 +156,8 @@ var retryErrorCodes = []int{
|
|||
func (f *Fs) shouldRetry(resp *http.Response, err error) (bool, error) {
|
||||
if resp != nil {
|
||||
if resp.StatusCode == 401 {
|
||||
f.ts.Invalidate()
|
||||
fs.Log(f, "401 error received - invalidating token")
|
||||
f.tokenRenewer.Invalidate()
|
||||
fs.Debug(f, "401 error received - invalidating token")
|
||||
return true, err
|
||||
}
|
||||
// Work around receiving this error sporadically on authentication
|
||||
|
|
|
@ -62,3 +62,8 @@ func (r *Renew) Start() {
|
|||
func (r *Renew) Stop() {
|
||||
atomic.AddInt32(&r.uploads, -1)
|
||||
}
|
||||
|
||||
// Invalidate invalidates the token source
|
||||
func (r *Renew) Invalidate() {
|
||||
r.ts.Invalidate()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user