mirror of
https://github.com/rclone/rclone.git
synced 2025-12-11 22:14:05 +01:00
oauthutil: improved debug logs from token refresh
Some checks failed
build / windows (push) Has been cancelled
build / other_os (push) Has been cancelled
build / mac_amd64 (push) Has been cancelled
build / mac_arm64 (push) Has been cancelled
build / linux (push) Has been cancelled
build / go1.24 (push) Has been cancelled
build / linux_386 (push) Has been cancelled
build / lint (push) Has been cancelled
build / android-all (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/386 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/amd64 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/arm/v6 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/arm/v7 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/arm64 (push) Has been cancelled
Build & Push Docker Images / Merge & Push Final Docker Image (push) Has been cancelled
Some checks failed
build / windows (push) Has been cancelled
build / other_os (push) Has been cancelled
build / mac_amd64 (push) Has been cancelled
build / mac_arm64 (push) Has been cancelled
build / linux (push) Has been cancelled
build / go1.24 (push) Has been cancelled
build / linux_386 (push) Has been cancelled
build / lint (push) Has been cancelled
build / android-all (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/386 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/amd64 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/arm/v6 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/arm/v7 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/arm64 (push) Has been cancelled
Build & Push Docker Images / Merge & Push Final Docker Image (push) Has been cancelled
This commit is contained in:
@@ -250,9 +250,7 @@ func (ts *TokenSource) reReadToken() (changed bool) {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if !newToken.Valid() {
|
if newToken.Valid() {
|
||||||
fs.Debugf(ts.name, "Loaded invalid token from config file - ignoring")
|
|
||||||
} else {
|
|
||||||
fs.Debugf(ts.name, "Loaded fresh token from config file")
|
fs.Debugf(ts.name, "Loaded fresh token from config file")
|
||||||
changed = true
|
changed = true
|
||||||
}
|
}
|
||||||
@@ -264,6 +262,8 @@ func (ts *TokenSource) reReadToken() (changed bool) {
|
|||||||
if changed {
|
if changed {
|
||||||
ts.token = newToken
|
ts.token = newToken
|
||||||
ts.tokenSource = nil // invalidate since we changed the token
|
ts.tokenSource = nil // invalidate since we changed the token
|
||||||
|
} else {
|
||||||
|
fs.Debugf(ts.name, "No updated token found in the config file")
|
||||||
}
|
}
|
||||||
return changed
|
return changed
|
||||||
}
|
}
|
||||||
@@ -319,6 +319,8 @@ func (ts *TokenSource) Token() (*oauth2.Token, error) {
|
|||||||
return ts.token, nil
|
return ts.token, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fs.Debug(ts.name, "Token expired")
|
||||||
|
|
||||||
// Try getting the token a few times
|
// Try getting the token a few times
|
||||||
for i := 1; i <= maxTries; i++ {
|
for i := 1; i <= maxTries; i++ {
|
||||||
// Try reading the token from the config file in case it has
|
// 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()
|
token, err = ts.tokenSource.Token()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
fs.Debug(ts.name, "Token refresh successful")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if newErr := maybeWrapOAuthError(err, ts.name); newErr != err {
|
if newErr := maybeWrapOAuthError(err, ts.name); newErr != err {
|
||||||
|
|||||||
@@ -47,16 +47,14 @@ func (r *Renew) renewOnExpiry() {
|
|||||||
}
|
}
|
||||||
uploads := r.uploads.Load()
|
uploads := r.uploads.Load()
|
||||||
if uploads != 0 {
|
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
|
// Do a transaction
|
||||||
err := r.run()
|
err := r.run()
|
||||||
if err == nil {
|
if err != nil {
|
||||||
fs.Debugf(r.name, "Token refresh successful")
|
fs.Errorf(r.name, "Background token refresher failed: %v", err)
|
||||||
} else {
|
|
||||||
fs.Errorf(r.name, "Token refresh failed: %v", err)
|
|
||||||
}
|
}
|
||||||
} else {
|
} 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