mirror of https://github.com/Xhofe/alist
Co-authored-by: Andy Hsu <i@nn.ci>pull/4341/head
parent
ee4ac81677
commit
b03879403f
|
@ -16,7 +16,6 @@ import (
|
|||
type Cloudreve struct {
|
||||
model.Storage
|
||||
Addition
|
||||
Cookie string
|
||||
}
|
||||
|
||||
func (d *Cloudreve) Config() driver.Config {
|
||||
|
|
|
@ -10,8 +10,9 @@ type Addition struct {
|
|||
driver.RootPath
|
||||
// define other
|
||||
Address string `json:"address" required:"true"`
|
||||
Username string `json:"username" required:"true"`
|
||||
Password string `json:"password" required:"true"`
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
Cookie string `json:"cookie"`
|
||||
}
|
||||
|
||||
var config = driver.Config{
|
||||
|
|
|
@ -49,13 +49,15 @@ func (d *Cloudreve) request(method string, path string, callback base.ReqCallbac
|
|||
|
||||
// 刷新 cookie
|
||||
if r.Code == http.StatusUnauthorized && path != loginPath {
|
||||
err = d.login()
|
||||
if err != nil {
|
||||
return err
|
||||
if d.Username != "" && d.Password != "" {
|
||||
err = d.login()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return d.request(method, path, callback, out)
|
||||
}
|
||||
return d.request(method, path, callback, out)
|
||||
}
|
||||
|
||||
|
||||
return errors.New(r.Msg)
|
||||
}
|
||||
sess := cookie.GetCookie(resp.Cookies(), "cloudreve-session")
|
||||
|
|
Loading…
Reference in New Issue