delete cache file

This commit is contained in:
微凉 2021-11-17 16:25:32 +08:00
parent e4d254e4b0
commit 36d52e0b75
3 changed files with 13 additions and 22 deletions

View File

@ -111,20 +111,15 @@ func (c Cloud189) Path(path string, account *model.Account) (*model.File, []*mod
log.Debugf("189 path: %s", path) log.Debugf("189 path: %s", path)
cache, err := conf.Cache.Get(conf.Ctx, fmt.Sprintf("%s%s", account.Name, path)) cache, err := conf.Cache.Get(conf.Ctx, fmt.Sprintf("%s%s", account.Name, path))
if err == nil { if err == nil {
file, ok := cache.(Cloud189File)
if ok {
return c.FormatFile(&file), nil, nil
} else {
files, _ := cache.([]Cloud189File) files, _ := cache.([]Cloud189File)
if len(files) != 0 { 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, c.FormatFile(&file)) res = append(res, c.FormatFile(&file))
} }
return nil, res, nil return nil, res, nil
} }
} }
}
// no cache or len(files) == 0 // no cache or len(files) == 0
fileId := account.RootFolder fileId := account.RootFolder
if path != "/" { if path != "/" {

View File

@ -230,20 +230,15 @@ func (a AliDrive) Path(path string, account *model.Account) (*model.File, []*mod
log.Debugf("ali path: %s", path) log.Debugf("ali path: %s", path)
cache, err := conf.Cache.Get(conf.Ctx, fmt.Sprintf("%s%s", account.Name, path)) cache, err := conf.Cache.Get(conf.Ctx, fmt.Sprintf("%s%s", account.Name, path))
if err == nil { if err == nil {
file, ok := cache.(AliFile)
if ok {
return a.FormatFile(&file), nil, nil
} else {
files, _ := cache.([]AliFile) files, _ := cache.([]AliFile)
if len(files) != 0 { 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
} }
} }
}
// no cache or len(files) == 0 // no cache or len(files) == 0
fileId := account.RootFolder fileId := account.RootFolder
if path != "/" { if path != "/" {

View File

@ -15,6 +15,7 @@ type Driver interface {
Proxy(c *gin.Context) Proxy(c *gin.Context)
Preview(path string, account *model.Account) (interface{}, error) Preview(path string, account *model.Account) (interface{}, error)
// TODO // TODO
//Search(path string, keyword string, account *model.Account) ([]*model.File, error)
//MakeDir(path string, account *model.Account) error //MakeDir(path string, account *model.Account) error
//Move(src string, des string, account *model.Account) error //Move(src string, des string, account *model.Account) error
//Delete(path string) error //Delete(path string) error