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 {
|
type Cloudreve struct {
|
||||||
model.Storage
|
model.Storage
|
||||||
Addition
|
Addition
|
||||||
Cookie string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Cloudreve) Config() driver.Config {
|
func (d *Cloudreve) Config() driver.Config {
|
||||||
|
|
|
@ -10,8 +10,9 @@ type Addition struct {
|
||||||
driver.RootPath
|
driver.RootPath
|
||||||
// define other
|
// define other
|
||||||
Address string `json:"address" required:"true"`
|
Address string `json:"address" required:"true"`
|
||||||
Username string `json:"username" required:"true"`
|
Username string `json:"username"`
|
||||||
Password string `json:"password" required:"true"`
|
Password string `json:"password"`
|
||||||
|
Cookie string `json:"cookie"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var config = driver.Config{
|
var config = driver.Config{
|
||||||
|
|
|
@ -49,13 +49,15 @@ func (d *Cloudreve) request(method string, path string, callback base.ReqCallbac
|
||||||
|
|
||||||
// 刷新 cookie
|
// 刷新 cookie
|
||||||
if r.Code == http.StatusUnauthorized && path != loginPath {
|
if r.Code == http.StatusUnauthorized && path != loginPath {
|
||||||
err = d.login()
|
if d.Username != "" && d.Password != "" {
|
||||||
if err != nil {
|
err = d.login()
|
||||||
return err
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return d.request(method, path, callback, out)
|
||||||
}
|
}
|
||||||
return d.request(method, path, callback, out)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return errors.New(r.Msg)
|
return errors.New(r.Msg)
|
||||||
}
|
}
|
||||||
sess := cookie.GetCookie(resp.Cookies(), "cloudreve-session")
|
sess := cookie.GetCookie(resp.Cookies(), "cloudreve-session")
|
||||||
|
|
Loading…
Reference in New Issue