Skip to content

Commit

Permalink
fix: delete cache if files is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Oct 25, 2022
1 parent 3e9c386 commit 0019959
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions internal/op/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down

0 comments on commit 0019959

Please sign in to comment.