diff --git a/drivers/xunlei/driver.go b/drivers/xunlei/driver.go index 135f3dde..4eb5b3bf 100644 --- a/drivers/xunlei/driver.go +++ b/drivers/xunlei/driver.go @@ -117,11 +117,9 @@ func (driver XunLeiCloud) Save(account *model.Account, old *model.Account) error client := GetClient(account) // 指定验证通过的captchaToken - if client.captchaToken != "" { - client.Lock() - client.captchaToken = account.CaptchaToken + if account.CaptchaToken != "" { + client.UpdateCaptchaToken(strings.TrimSpace(account.CaptchaToken)) account.CaptchaToken = "" - client.Unlock() } if client.token == "" { diff --git a/drivers/xunlei/xunlei.go b/drivers/xunlei/xunlei.go index 4ab1a43f..2c966c99 100644 --- a/drivers/xunlei/xunlei.go +++ b/drivers/xunlei/xunlei.go @@ -269,3 +269,14 @@ func (c *Client) Request(method string, url string, callback func(*resty.Request } return c.Request(method, url, callback, account) } + +func (c *Client) UpdateCaptchaToken(captchaToken string) bool { + c.Lock() + defer c.Unlock() + + if captchaToken != "" { + c.captchaToken = captchaToken + return true + } + return false +}