mirror of
https://github.com/rclone/rclone.git
synced 2026-01-03 00:53:43 +00:00
oauthutil: improved debug logs from token refresh
This commit is contained in:
@@ -250,9 +250,7 @@ func (ts *TokenSource) reReadToken() (changed bool) {
|
||||
return false
|
||||
}
|
||||
|
||||
if !newToken.Valid() {
|
||||
fs.Debugf(ts.name, "Loaded invalid token from config file - ignoring")
|
||||
} else {
|
||||
if newToken.Valid() {
|
||||
fs.Debugf(ts.name, "Loaded fresh token from config file")
|
||||
changed = true
|
||||
}
|
||||
@@ -264,6 +262,8 @@ func (ts *TokenSource) reReadToken() (changed bool) {
|
||||
if changed {
|
||||
ts.token = newToken
|
||||
ts.tokenSource = nil // invalidate since we changed the token
|
||||
} else {
|
||||
fs.Debugf(ts.name, "No updated token found in the config file")
|
||||
}
|
||||
return changed
|
||||
}
|
||||
@@ -319,6 +319,8 @@ func (ts *TokenSource) Token() (*oauth2.Token, error) {
|
||||
return ts.token, nil
|
||||
}
|
||||
|
||||
fs.Debug(ts.name, "Token expired")
|
||||
|
||||
// Try getting the token a few times
|
||||
for i := 1; i <= maxTries; i++ {
|
||||
// Try reading the token from the config file in case it has
|
||||
@@ -344,6 +346,7 @@ func (ts *TokenSource) Token() (*oauth2.Token, error) {
|
||||
|
||||
token, err = ts.tokenSource.Token()
|
||||
if err == nil {
|
||||
fs.Debug(ts.name, "Token refresh successful")
|
||||
break
|
||||
}
|
||||
if newErr := maybeWrapOAuthError(err, ts.name); newErr != err {
|
||||
|
||||
@@ -47,16 +47,14 @@ func (r *Renew) renewOnExpiry() {
|
||||
}
|
||||
uploads := r.uploads.Load()
|
||||
if uploads != 0 {
|
||||
fs.Debugf(r.name, "Token expired - %d uploads in progress - refreshing", uploads)
|
||||
fs.Debugf(r.name, "Background refresher detected expired token - %d uploads in progress - refreshing", uploads)
|
||||
// Do a transaction
|
||||
err := r.run()
|
||||
if err == nil {
|
||||
fs.Debugf(r.name, "Token refresh successful")
|
||||
} else {
|
||||
fs.Errorf(r.name, "Token refresh failed: %v", err)
|
||||
if err != nil {
|
||||
fs.Errorf(r.name, "Background token refresher failed: %v", err)
|
||||
}
|
||||
} else {
|
||||
fs.Debugf(r.name, "Token expired but no uploads in progress - doing nothing")
|
||||
fs.Debugf(r.name, "Background refresher detected expired token but no uploads in progress - doing nothing")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user