From 36d52e0b750a8f3d67ffe071b3843fbafdcb5245 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=AE=E5=87=89?= <927625802@qq.com> Date: Wed, 17 Nov 2021 16:25:32 +0800 Subject: [PATCH] :sparkles: delete cache file --- drivers/189.go | 17 ++++++----------- drivers/alidrive.go | 17 ++++++----------- drivers/driver.go | 1 + 3 files changed, 13 insertions(+), 22 deletions(-) diff --git a/drivers/189.go b/drivers/189.go index 768fe772..8c1a2dca 100644 --- a/drivers/189.go +++ b/drivers/189.go @@ -111,18 +111,13 @@ func (c Cloud189) Path(path string, account *model.Account) (*model.File, []*mod log.Debugf("189 path: %s", path) cache, err := conf.Cache.Get(conf.Ctx, fmt.Sprintf("%s%s", account.Name, path)) if err == nil { - file, ok := cache.(Cloud189File) - if ok { - return c.FormatFile(&file), nil, nil - } else { - files, _ := cache.([]Cloud189File) - if len(files) != 0 { - res := make([]*model.File, 0) - for _, file = range files { - res = append(res, c.FormatFile(&file)) - } - return nil, res, nil + files, _ := cache.([]Cloud189File) + if len(files) != 0 { + res := make([]*model.File, 0) + for _, file := range files { + res = append(res, c.FormatFile(&file)) } + return nil, res, nil } } // no cache or len(files) == 0 diff --git a/drivers/alidrive.go b/drivers/alidrive.go index 6e37ec1b..bcbc3b0d 100644 --- a/drivers/alidrive.go +++ b/drivers/alidrive.go @@ -230,18 +230,13 @@ func (a AliDrive) Path(path string, account *model.Account) (*model.File, []*mod log.Debugf("ali path: %s", path) cache, err := conf.Cache.Get(conf.Ctx, fmt.Sprintf("%s%s", account.Name, path)) if err == nil { - file, ok := cache.(AliFile) - if ok { - return a.FormatFile(&file), nil, nil - } else { - files, _ := cache.([]AliFile) - if len(files) != 0 { - res := make([]*model.File, 0) - for _, file = range files { - res = append(res, a.FormatFile(&file)) - } - return nil, res, nil + files, _ := cache.([]AliFile) + if len(files) != 0 { + res := make([]*model.File, 0) + for _, file := range files { + res = append(res, a.FormatFile(&file)) } + return nil, res, nil } } // no cache or len(files) == 0 diff --git a/drivers/driver.go b/drivers/driver.go index 2e8c29b8..06db854b 100644 --- a/drivers/driver.go +++ b/drivers/driver.go @@ -15,6 +15,7 @@ type Driver interface { Proxy(c *gin.Context) Preview(path string, account *model.Account) (interface{}, error) // TODO + //Search(path string, keyword string, account *model.Account) ([]*model.File, error) //MakeDir(path string, account *model.Account) error //Move(src string, des string, account *model.Account) error //Delete(path string) error