github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/kbfs/libdokan/reset_caches_file.go (about) 1 // Copyright 2016 Keybase Inc. All rights reserved. 2 // Use of this source code is governed by a BSD 3 // license that can be found in the LICENSE file. 4 5 package libdokan 6 7 import ( 8 "github.com/keybase/client/go/kbfs/dokan" 9 "github.com/keybase/client/go/kbfs/libkbfs" 10 "golang.org/x/net/context" 11 ) 12 13 // ResetCachesFile represents a write-only file where any write of at 14 // least one byte triggers the resetting of all data caches. It can 15 // only be reached from the top-level FS mount. Note that it does not 16 // clear the *node* cache, which means that the BlockPointers for 17 // existing nodes are still cached, such that directory listings can 18 // still be implicitly cached for nodes still being held by callers. 19 type ResetCachesFile struct { 20 fs *FS 21 specialWriteFile 22 } 23 24 // WriteFile implements writes for dokan. 25 func (f *ResetCachesFile) WriteFile(ctx context.Context, fi *dokan.FileInfo, bs []byte, offset int64) (n int, err error) { 26 f.fs.logEnter(ctx, "ResetCachesFile Write") 27 defer func() { f.fs.reportErr(ctx, libkbfs.WriteMode, err) }() 28 if len(bs) == 0 { 29 return 0, nil 30 } 31 f.fs.config.ResetCaches() 32 return len(bs), nil 33 }