"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: Move DefaultOpt to vfs and make some methods private
Nick Craig-Wood3e0c91ba4b93
diff --git a/vfs/dir.go b/vfs/dir.goindex 950180650..7ba6a96a3 100644--- a/vfs/dir.go+++ b/vfs/dir.go@@ -34,7 +34,7 @@ func newDir(vfs *VFS, f fs.Fs, parent *Dir, fsDir fs.Directory) *Dir {entry: fsDir,path: fsDir.Remote(),modTime: fsDir.ModTime(),- inode: NewInode(),+ inode: newInode(),}}diff --git a/vfs/file.go b/vfs/file.goindex d0d2133eb..0dc9e711c 100644--- a/vfs/file.go+++ b/vfs/file.go@@ -29,7 +29,7 @@ func newFile(d *Dir, o fs.Object, leaf string) *File {d: d,o: o,leaf: leaf,- inode: NewInode(),+ inode: newInode(),}}diff --git a/vfs/vfs.go b/vfs/vfs.goindex 7818761aa..c5d2828a2 100644--- a/vfs/vfs.go+++ b/vfs/vfs.go@@ -19,6 +19,21 @@ import ("github.com/ncw/rclone/fs")+// DefaultOpt is the default values uses for Opt+var DefaultOpt = Options{+ NoModTime: false,+ NoChecksum: false,+ NoSeek: false,+ DirCacheTime: 5 * 60 * time.Second,+ PollInterval: time.Minute,+ ReadOnly: false,+ Umask: 0,+ UID: ^uint32(0), // these values instruct WinFSP-FUSE to use the current user+ GID: ^uint32(0), // overriden for non windows in mount_unix.go+ DirPerms: os.FileMode(0777),+ FilePerms: os.FileMode(0666),+}+// Node represents either a directory (*Dir) or a file (*File)type Node interface {os.FileInfo@@ -83,12 +98,18 @@ type Options struct {}// New creates a new VFS and root directory. If opt is nil, then-// defaults will be used.+// DefaultOpt will be usedfunc New(f fs.Fs, opt *Options) *VFS {fsDir := fs.NewDir("", time.Now())vfs := &VFS{- f: f,- Opt: *opt,+ f: f,+ }++ // Make a copy of the options+ if opt != nil {+ vfs.Opt = *opt+ } else {+ vfs.Opt = DefaultOpt}// Mask the permissions with the umask@@ -100,18 +121,9 @@ func New(f fs.Fs, opt *Options) *VFS {// Start polling if requiredif vfs.Opt.PollInterval > 0 {- vfs.PollChanges(vfs.Opt.PollInterval)- }- return vfs-}--// PollChanges will poll the remote every pollInterval for changes if the remote-// supports it. If a non-polling option is used, the given time interval can be-// ignored-func (vfs *VFS) PollChanges(pollInterval time.Duration) *VFS {- doDirChangeNotify := vfs.f.Features().DirChangeNotify- if doDirChangeNotify != nil {- doDirChangeNotify(vfs.root.ForgetPath, pollInterval)+ if do := vfs.f.Features().DirChangeNotify; do != nil {+ do(vfs.root.ForgetPath, vfs.Opt.PollInterval)+ }}return vfs}@@ -124,8 +136,8 @@ func (vfs *VFS) Root() (*Dir, error) {var inodeCount uint64-// NewInode creates a new unique inode number-func NewInode() (inode uint64) {+// newInode creates a new unique inode number+func newInode() (inode uint64) {return atomic.AddUint64(&inodeCount, 1)}diff --git a/vfs/vfsflags/vfsflags.go b/vfs/vfsflags/vfsflags.goindex 053213079..265587cb3 100644--- a/vfs/vfsflags/vfsflags.go+++ b/vfs/vfsflags/vfsflags.go@@ -2,28 +2,13 @@package vfsflagsimport (- "os"- "time"-"github.com/ncw/rclone/vfs""github.com/spf13/pflag")// Options set by command line flagsvar (- Opt = vfs.Options{- NoModTime: false,- NoChecksum: false,- NoSeek: false,- DirCacheTime: 5 * 60 * time.Second,- PollInterval: time.Minute,- ReadOnly: false,- Umask: 0,- UID: ^uint32(0), // these values instruct WinFSP-FUSE to use the current user- GID: ^uint32(0), // overriden for non windows in mount_unix.go- DirPerms: os.FileMode(0777),- FilePerms: os.FileMode(0666),- }+ Opt = vfs.DefaultOpt)// AddFlags adds the non filing system specific flags to the command