mirror of
https://github.com/rclone/rclone.git
synced 2025-12-11 22:14:05 +01:00
vfs: Add SetSys() methods to Node to allow caching stuff on a node
This commit is contained in:
12
vfs/file.go
12
vfs/file.go
@@ -52,6 +52,7 @@ type File struct {
|
||||
pendingModTime time.Time // will be applied once o becomes available, i.e. after file was written
|
||||
pendingRenameFun func(ctx context.Context) error // will be run/renamed after all writers close
|
||||
appendMode bool // file was opened with O_APPEND
|
||||
sys interface{} // user defined info to be attached here
|
||||
|
||||
muRW sync.Mutex // synchonize RWFileHandle.openPending(), RWFileHandle.close() and File.Remove
|
||||
}
|
||||
@@ -130,7 +131,16 @@ func (f *File) osPath() string {
|
||||
|
||||
// Sys returns underlying data source (can be nil) - satisfies Node interface
|
||||
func (f *File) Sys() interface{} {
|
||||
return nil
|
||||
f.mu.RLock()
|
||||
defer f.mu.RUnlock()
|
||||
return f.sys
|
||||
}
|
||||
|
||||
// SetSys sets the underlying data source (can be nil) - satisfies Node interface
|
||||
func (f *File) SetSys(x interface{}) {
|
||||
f.mu.Lock()
|
||||
f.sys = x
|
||||
f.mu.Unlock()
|
||||
}
|
||||
|
||||
// Inode returns the inode number - satisfies Node interface
|
||||
|
||||
Reference in New Issue
Block a user