From 0019959eec3799f9450737d3a2dffc57c24611ae Mon Sep 17 00:00:00 2001 From: Noah Hsu Date: Tue, 25 Oct 2022 16:42:06 +0800 Subject: [PATCH] fix: delete cache if files is empty --- internal/op/fs.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/op/fs.go b/internal/op/fs.go index e7e0e85f..94207d8b 100644 --- a/internal/op/fs.go +++ b/internal/op/fs.go @@ -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 { - listCache.Set(key, files, cache.WithEx[[]model.Obj](time.Minute*time.Duration(storage.GetStorage().CacheExpiration))) + 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 })