mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2026-11-10 20:50:50 +08:00
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:
2 files changed
+6
-4
No files matched your search
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user