Skip to content

Commit

Permalink
🐛 fix alist path error
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Jan 2, 2022
1 parent e789873 commit efeee0e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
8 changes: 6 additions & 2 deletions drivers/alist/alist.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ type BaseResp struct {

type PathResp struct {
BaseResp
Data []model.File `json:"data"`
Data struct {
Type string `json:"type"`
//Meta Meta `json:"meta"`
Files []model.File `json:"files"`
} `json:"data"`
}

type PreviewResp struct {
Expand All @@ -25,7 +29,7 @@ func (driver *Alist) Login(account *model.Account) error {
var resp BaseResp
_, err := base.RestyClient.R().SetResult(&resp).
SetHeader("Authorization", account.AccessToken).
Get(account.SiteUrl+"/api/admin/login")
Get(account.SiteUrl + "/api/admin/login")
if err != nil {
return err
}
Expand Down
10 changes: 5 additions & 5 deletions drivers/alist/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,13 @@ func (driver Alist) Path(path string, account *model.Account) (*model.File, []mo
if resp.Code != 200 {
return nil, nil, errors.New(resp.Message)
}
if resp.Message == "file" {
return &resp.Data[0], nil, nil
if resp.Data.Type == "file" {
return &resp.Data.Files[0], nil, nil
}
if len(resp.Data) > 0 {
_ = base.SetCache(path, resp.Data, account)
if len(resp.Data.Files) > 0 {
_ = base.SetCache(path, resp.Data.Files, account)
}
return nil, resp.Data, nil
return nil, resp.Data.Files, nil
}

func (driver Alist) Proxy(c *gin.Context, account *model.Account) {}
Expand Down

0 comments on commit efeee0e

Please sign in to comment.