feat: add `NoCache` config for driver

refactor/fs
Noah Hsu 2022-06-13 21:15:58 +08:00
parent c525406516
commit 6accc2eff6
2 changed files with 4 additions and 0 deletions

View File

@ -6,4 +6,5 @@ type Config struct {
OnlyLocal bool OnlyLocal bool
OnlyProxy bool OnlyProxy bool
NoNeedSetLink bool NoNeedSetLink bool
NoCache bool
} }

View File

@ -20,6 +20,9 @@ var filesG singleflight.Group[[]driver.FileInfo]
// List files in storage, not contains virtual file // List files in storage, not contains virtual file
func List(ctx context.Context, account driver.Driver, path string) ([]driver.FileInfo, error) { func List(ctx context.Context, account driver.Driver, path string) ([]driver.FileInfo, error) {
if account.Config().NoCache {
return account.List(ctx, path)
}
key := stdpath.Join(account.GetAccount().VirtualPath, path) key := stdpath.Join(account.GetAccount().VirtualPath, path)
if files, ok := filesCache.Get(key); ok { if files, ok := filesCache.Get(key); ok {
return files, nil return files, nil