fix: delete cache if files is empty

pull/2122/head
Noah Hsu 2022-10-25 16:42:06 +08:00
parent 3e9c38697d
commit 0019959eec
1 changed files with 6 additions and 2 deletions

View File

@ -58,8 +58,12 @@ func List(ctx context.Context, storage driver.Driver, path string, args model.Li
if err != nil {
return nil, errors.Wrapf(err, "failed to list objs")
}
if !storage.Config().NoCache && len(files) > 0 {
if !storage.Config().NoCache {
if len(files) > 0 {
listCache.Set(key, files, cache.WithEx[[]model.Obj](time.Minute*time.Duration(storage.GetStorage().CacheExpiration)))
} else {
listCache.Del(key)
}
}
return files, nil
})