fix(drivers/onedrive): refresh token on drive quota query and retry only once (#3335)

fix(onedrive): refresh token on drive quota query and retry only once

getDrive (used for storage capacity) was the only request that opted out
of the InvalidAuthenticationToken refresh, so an expired token made the
capacity query fail until another request happened to refresh it. Let it
refresh like every other request.

The retry after a refresh did not pass noRetry, so a token that stayed
invalid after a successful refresh recursed without bound. Retry once.


Claude-Session: https://claude.ai/code/session_01U5btuswaVrY7Lp7FWWVEHh

Co-authored-by: Vurliy <ulermi@outlook.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
authored and GitHub committed 2026-11-06 12:42:33 +08:00
1 parent db581fc6c9
commit d09af74a75
2 files changed
+6 -4

No files matched your search

+3 -2
View File
@@ -156,7 +156,8 @@ func (d *Onedrive) Request(url string, method string, callback base.ReqCallback,
if err != nil {
return nil, err
}
return d.Request(url, method, callback, resp)
// retry once with the refreshed token, never loop on a bad token
return d.Request(url, method, callback, resp, true)
}
return nil, errors.New(e.Error.Message)
}
@@ -310,7 +311,7 @@ func (d *Onedrive) getDrive(ctx context.Context) (*DriveResp, error) {
var resp DriveResp
_, err := d.Request(api, http.MethodGet, func(req *resty.Request) {
req.SetContext(ctx)
}, &resp, true)
}, &resp)
if err != nil {
return nil, err
}
+3 -2
View File
@@ -182,7 +182,8 @@ func (d *OnedriveAPP) Request(url string, method string, callback base.ReqCallba
if err != nil {
return nil, err
}
return d.Request(url, method, callback, resp)
// retry once with the refreshed token, never loop on a bad token
return d.Request(url, method, callback, resp, true)
}
return nil, errors.New(e.Error.Message)
}
@@ -295,7 +296,7 @@ func (d *OnedriveAPP) getDrive(ctx context.Context) (*DriveResp, error) {
var resp DriveResp
_, err := d.Request(api, http.MethodGet, func(req *resty.Request) {
req.SetContext(ctx)
}, &resp, true)
}, &resp)
if err != nil {
return nil, err
}