mirror of https://github.com/Xhofe/alist
✨ cache len(files)=0: request
parent
b46bf0dfc9
commit
7e099b39cf
|
@ -221,13 +221,16 @@ func (a AliDrive) Path(path string, account *model.Account) (*model.File, []*mod
|
||||||
return a.FormatFile(&file), nil, nil
|
return a.FormatFile(&file), nil, nil
|
||||||
} else {
|
} else {
|
||||||
files, _ := cache.([]AliFile)
|
files, _ := cache.([]AliFile)
|
||||||
|
if len(files) != 0 {
|
||||||
res := make([]*model.File, 0)
|
res := make([]*model.File, 0)
|
||||||
for _, file = range files {
|
for _, file = range files {
|
||||||
res = append(res, a.FormatFile(&file))
|
res = append(res, a.FormatFile(&file))
|
||||||
}
|
}
|
||||||
return nil, res, nil
|
return nil, res, nil
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
|
// no cache or len(files) == 0
|
||||||
fileId := account.RootFolder
|
fileId := account.RootFolder
|
||||||
if path != "/" {
|
if path != "/" {
|
||||||
dir, name := filepath.Split(path)
|
dir, name := filepath.Split(path)
|
||||||
|
@ -270,7 +273,6 @@ func (a AliDrive) Path(path string, account *model.Account) (*model.File, []*mod
|
||||||
}
|
}
|
||||||
return nil, res, nil
|
return nil, res, nil
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func (a AliDrive) Link(path string, account *model.Account) (string, error) {
|
func (a AliDrive) Link(path string, account *model.Account) (string, error) {
|
||||||
file, err := a.GetFile(utils.ParsePath(path), account)
|
file, err := a.GetFile(utils.ParsePath(path), account)
|
||||||
|
@ -316,10 +318,12 @@ func (a AliDrive) RefreshToken(account *model.Account) error {
|
||||||
SetError(&e).
|
SetError(&e).
|
||||||
Post(url)
|
Post(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
account.Status = err.Error()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Debugf("%+v,%+v", resp, e)
|
log.Debugf("%+v,%+v", resp, e)
|
||||||
if e.Code != "" {
|
if e.Code != "" {
|
||||||
|
account.Status = e.Message
|
||||||
return fmt.Errorf("failed to refresh token: %s", e.Message)
|
return fmt.Errorf("failed to refresh token: %s", e.Message)
|
||||||
}
|
}
|
||||||
account.RefreshToken, account.AccessToken = resp.RefreshToken, resp.AccessToken
|
account.RefreshToken, account.AccessToken = resp.RefreshToken, resp.AccessToken
|
||||||
|
@ -354,9 +358,6 @@ func (a AliDrive) Save(account *model.Account, old *model.Account) error {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = a.RefreshToken(&newAccount)
|
err = a.RefreshToken(&newAccount)
|
||||||
if err != nil {
|
|
||||||
newAccount.Status = err.Error()
|
|
||||||
}
|
|
||||||
_ = model.SaveAccount(newAccount)
|
_ = model.SaveAccount(newAccount)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue