perf(baidu): avoid refreshing the token on every startup

pull/4546/head
Andy Hsu 2023-06-02 18:31:42 +08:00
parent 5141b3c165
commit b124fdc092
2 changed files with 6 additions and 2 deletions

View File

@ -23,7 +23,6 @@ import (
type BaiduNetdisk struct {
model.Storage
Addition
AccessToken string
}
func (d *BaiduNetdisk) Config() driver.Config {
@ -35,7 +34,11 @@ func (d *BaiduNetdisk) GetAddition() driver.Additional {
}
func (d *BaiduNetdisk) Init(ctx context.Context) error {
return d.refreshToken()
res, err := d.get("/xpan/nas", map[string]string{
"method": "uinfo",
}, nil)
log.Debugf("[baidu] get uinfo: %s", string(res))
return err
}
func (d *BaiduNetdisk) Drop(ctx context.Context) error {

View File

@ -13,6 +13,7 @@ type Addition struct {
DownloadAPI string `json:"download_api" type:"select" options:"official,crack" default:"official"`
ClientID string `json:"client_id" required:"true" default:"iYCeC9g08h5vuP9UqvPHKKSVrKFXGa1v"`
ClientSecret string `json:"client_secret" required:"true" default:"jXiFMOPVPCWlO2M5CwWQzffpNPaGTRBG"`
AccessToken string
}
var config = driver.Config{