From 09492193c4640714627be3a7f5dc554afde9297f Mon Sep 17 00:00:00 2001 From: Andy Hsu Date: Mon, 20 Feb 2023 16:15:52 +0800 Subject: [PATCH] fix(alist_v3): api error pass (close #3326) --- drivers/alist_v3/driver.go | 7 +++++++ drivers/alist_v3/util.go | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/alist_v3/driver.go b/drivers/alist_v3/driver.go index 41b8510b..62999555 100644 --- a/drivers/alist_v3/driver.go +++ b/drivers/alist_v3/driver.go @@ -2,6 +2,7 @@ package alist_v3 import ( "context" + "errors" "io" "path" "strconv" @@ -55,6 +56,9 @@ func (d *AListV3) List(ctx context.Context, dir model.Obj, args model.ListArgs) if err != nil { return nil, err } + if resp.Code != 200 { + return nil, errors.New(resp.Message) + } var files []model.Obj for _, f := range resp.Data.Content { file := model.ObjThumb{ @@ -84,6 +88,9 @@ func (d *AListV3) Link(ctx context.Context, file model.Obj, args model.LinkArgs) if err != nil { return nil, err } + if resp.Code != 200 { + return nil, errors.New(resp.Message) + } return &model.Link{ URL: resp.Data.RawURL, }, nil diff --git a/drivers/alist_v3/util.go b/drivers/alist_v3/util.go index 18920e05..5682d624 100644 --- a/drivers/alist_v3/util.go +++ b/drivers/alist_v3/util.go @@ -10,7 +10,7 @@ func checkResp(resp common.Resp[interface{}], err error) error { if err != nil { return err } - if resp.Message == "success" { + if resp.Code == 200 { return nil } return errors.New(resp.Message)