From b124fdc09255496954117efa1619c3e4658db6c7 Mon Sep 17 00:00:00 2001 From: Andy Hsu Date: Fri, 2 Jun 2023 18:31:42 +0800 Subject: [PATCH] perf(baidu): avoid refreshing the token on every startup --- drivers/baidu_netdisk/driver.go | 7 +++++-- drivers/baidu_netdisk/meta.go | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/baidu_netdisk/driver.go b/drivers/baidu_netdisk/driver.go index fe1a6ddb..64510dcf 100644 --- a/drivers/baidu_netdisk/driver.go +++ b/drivers/baidu_netdisk/driver.go @@ -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 { diff --git a/drivers/baidu_netdisk/meta.go b/drivers/baidu_netdisk/meta.go index 9feca299..cf9a89eb 100644 --- a/drivers/baidu_netdisk/meta.go +++ b/drivers/baidu_netdisk/meta.go @@ -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{