From 5c8bd27c7fb8af27c8476e8bc13f86c23d55607c Mon Sep 17 00:00:00 2001 From: Filipe Azevedo Date: Wed, 17 Aug 2022 00:33:58 +0200 Subject: [PATCH] vfs: Add VFS --links command line switch This will be used to enable links support for the various mount engines in a follow up commit. --- vfs/help.go | 1 + vfs/vfs.go | 5 +++++ vfs/vfscommon/options.go | 2 ++ vfs/vfsflags/vfsflags.go | 2 ++ 4 files changed, 10 insertions(+) diff --git a/vfs/help.go b/vfs/help.go index 84ad2dc9d..cb3089d69 100644 --- a/vfs/help.go +++ b/vfs/help.go @@ -258,6 +258,7 @@ read of the modification time takes a transaction. --no-modtime Don't read/write the modification time (can speed things up). --no-seek Don't allow seeking in files. --read-only Only allow read-only access. + --links Translate symlinks to/from regular files with a '.rclonelink' extension. Sometimes rclone is delivered reads or writes out of order. Rather than seeking rclone will wait a short time for the in sequence read or diff --git a/vfs/vfs.go b/vfs/vfs.go index 7e9b0043f..984d64775 100644 --- a/vfs/vfs.go +++ b/vfs/vfs.go @@ -227,6 +227,11 @@ func New(f fs.Fs, opt *vfscommon.Options) *VFS { fs.Logf(f, "--vfs-cache-mode writes or full is recommended for this remote as it can't stream") } + // Warn if we handle symlinks + if vfs.Opt.Links { + fs.Logf(f, "Symlinks support enabled") + } + vfs.SetCacheMode(vfs.Opt.CacheMode) // Pin the Fs into the cache so that when we use cache.NewFs diff --git a/vfs/vfscommon/options.go b/vfs/vfscommon/options.go index c3631859a..c5fef88a7 100644 --- a/vfs/vfscommon/options.go +++ b/vfs/vfscommon/options.go @@ -13,6 +13,7 @@ type Options struct { NoSeek bool // don't allow seeking if set NoChecksum bool // don't check checksums if set ReadOnly bool // if set VFS is read only + Links bool // if set VFS handle symlinks NoModTime bool // don't read mod times for files DirCacheTime time.Duration // how long to consider directory listing cache valid PollInterval time.Duration @@ -45,6 +46,7 @@ var DefaultOpt = Options{ DirCacheTime: 5 * 60 * time.Second, PollInterval: time.Minute, ReadOnly: false, + Links: false, Umask: 0, UID: ^uint32(0), // these values instruct WinFSP-FUSE to use the current user GID: ^uint32(0), // overridden for non windows in mount_unix.go diff --git a/vfs/vfsflags/vfsflags.go b/vfs/vfsflags/vfsflags.go index ccdcb17db..d19e1523c 100644 --- a/vfs/vfsflags/vfsflags.go +++ b/vfs/vfsflags/vfsflags.go @@ -2,6 +2,7 @@ package vfsflags import ( + "github.com/rclone/rclone/fs" "github.com/rclone/rclone/fs/config/flags" "github.com/rclone/rclone/fs/rc" "github.com/rclone/rclone/vfs/vfscommon" @@ -24,6 +25,7 @@ func AddFlags(flagSet *pflag.FlagSet) { flags.DurationVarP(flagSet, &Opt.DirCacheTime, "dir-cache-time", "", Opt.DirCacheTime, "Time to cache directory entries for") flags.DurationVarP(flagSet, &Opt.PollInterval, "poll-interval", "", Opt.PollInterval, "Time to wait between polling for changes, must be smaller than dir-cache-time and only on supported remotes (set 0 to disable)") flags.BoolVarP(flagSet, &Opt.ReadOnly, "read-only", "", Opt.ReadOnly, "Only allow read-only access") + flags.BoolVarP(flagSet, &Opt.Links, "links", "l", Opt.Links, "Translate symlinks to/from regular files with a '"+fs.LinkSuffix+"' extension") flags.FVarP(flagSet, &Opt.CacheMode, "vfs-cache-mode", "", "Cache mode off|minimal|writes|full") flags.DurationVarP(flagSet, &Opt.CachePollInterval, "vfs-cache-poll-interval", "", Opt.CachePollInterval, "Interval to poll the cache for stale objects") flags.DurationVarP(flagSet, &Opt.CacheMaxAge, "vfs-cache-max-age", "", Opt.CacheMaxAge, "Max age of objects in the cache")