"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
vfs: Add SetSys() methods to Node to allow caching stuff on a node
Nick Craig-Woodcfcdc85b260f
diff --git a/vfs/dir.go b/vfs/dir.goindex 25af0cb97..960bc1569 100644--- a/vfs/dir.go+++ b/vfs/dir.go@@ -32,6 +32,7 @@ type Dir struct {entry fs.Directoryread time.Time // time directory entry last readitems map[string]Node // directory entries - can be empty but not nil+ sys interface{} // user defined info to be attached here}func newDir(vfs *VFS, f fs.Fs, parent *Dir, fsDir fs.Directory) *Dir {@@ -92,7 +93,16 @@ func (d *Dir) Path() (name string) {// Sys returns underlying data source (can be nil) - satisfies Node interfacefunc (d *Dir) Sys() interface{} {- return nil+ d.mu.RLock()+ defer d.mu.RUnlock()+ return d.sys+}++// SetSys sets the underlying data source (can be nil) - satisfies Node interface+func (d *Dir) SetSys(x interface{}) {+ d.mu.Lock()+ d.sys = x+ d.mu.Unlock()}// Inode returns the inode number - satisfies Node interfacediff --git a/vfs/dir_test.go b/vfs/dir_test.goindex 51dcefd50..81b6bb3d3 100644--- a/vfs/dir_test.go+++ b/vfs/dir_test.go@@ -54,6 +54,10 @@ func TestDirMethods(t *testing.T) {// Sysassert.Equal(t, nil, dir.Sys())+ // SetSys+ dir.SetSys(42)+ assert.Equal(t, 42, dir.Sys())+// Inodeassert.NotEqual(t, uint64(0), dir.Inode())diff --git a/vfs/file.go b/vfs/file.goindex 4ef4cf0f2..41ffc6784 100644--- a/vfs/file.go+++ b/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 writtenpendingRenameFun func(ctx context.Context) error // will be run/renamed after all writers closeappendMode bool // file was opened with O_APPEND+ sys interface{} // user defined info to be attached heremuRW 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 interfacefunc (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 interfacediff --git a/vfs/file_test.go b/vfs/file_test.goindex 31f5351c5..f74788358 100644--- a/vfs/file_test.go+++ b/vfs/file_test.go@@ -58,6 +58,10 @@ func TestFileMethods(t *testing.T) {// Sysassert.Equal(t, nil, file.Sys())+ // SetSys+ file.SetSys(42)+ assert.Equal(t, 42, file.Sys())+// Inodeassert.NotEqual(t, uint64(0), file.Inode())diff --git a/vfs/vfs.go b/vfs/vfs.goindex 9e0eaa59b..258722fc5 100644--- a/vfs/vfs.go+++ b/vfs/vfs.go@@ -54,6 +54,7 @@ type Node interface {Open(flags int) (Handle, error)Truncate(size int64) errorPath() string+ SetSys(interface{})}// Check interfaces