mirror of
https://github.com/rclone/rclone.git
synced 2025-01-24 12:56:36 +02:00
mount: make mount/mount remote control take vfsOpt option
See: https://forum.rclone.org/t/passing-mount-options-like-vfs-cache-mode-when-using-rclone-rc-mount-mount/17863
This commit is contained in:
parent
2871268505
commit
26b4698212
@ -55,11 +55,18 @@ This takes the following parameters
|
||||
- fs - a remote path to be mounted (required)
|
||||
- mountPoint: valid path on the local machine (required)
|
||||
- mountType: One of the values (mount, cmount, mount2) specifies the mount implementation to use
|
||||
- vfsOpt: a JSON object with VFS options in.
|
||||
|
||||
Eg
|
||||
|
||||
rclone rc mount/mount fs=mydrive: mountPoint=/home/<user>/mountPoint
|
||||
rclone rc mount/mount fs=mydrive: mountPoint=/home/<user>/mountPoint mountType=mount
|
||||
rclone rc mount/mount fs=TestDrive: mountPoint=/mnt/tmp vfsOpt='{"CacheMode": 2}'
|
||||
|
||||
The vfsOpt are as described in options/get and can be seen in the the
|
||||
"vfs" section when running:
|
||||
|
||||
rclone rc options/get
|
||||
`,
|
||||
})
|
||||
}
|
||||
@ -71,6 +78,12 @@ func mountRc(_ context.Context, in rc.Params) (out rc.Params, err error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
vfsOpt := vfsflags.Opt
|
||||
err = in.GetStructMissingOK("vfsOpt", &vfsOpt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
mountType, err := in.GetString("mountType")
|
||||
|
||||
mountMu.Lock()
|
||||
@ -93,7 +106,7 @@ func mountRc(_ context.Context, in rc.Params) (out rc.Params, err error) {
|
||||
}
|
||||
|
||||
if mountFns[mountType] != nil {
|
||||
VFS := vfs.New(fdst, &vfsflags.Opt)
|
||||
VFS := vfs.New(fdst, &vfsOpt)
|
||||
_, unmountFn, err := mountFns[mountType](VFS, mountPoint)
|
||||
|
||||
if err != nil {
|
||||
|
@ -68,6 +68,9 @@ func TestRc(t *testing.T) {
|
||||
in := rc.Params{
|
||||
"fs": localDir,
|
||||
"mountPoint": mountPoint,
|
||||
"vfsOpt": rc.Params{
|
||||
"FilePerms": 0400,
|
||||
},
|
||||
}
|
||||
|
||||
// check file.txt is not there
|
||||
@ -86,6 +89,9 @@ func TestRc(t *testing.T) {
|
||||
fi, err := os.Stat(filePath)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, int64(5), fi.Size())
|
||||
if runtime.GOOS == "linux" {
|
||||
assert.Equal(t, os.FileMode(0400), fi.Mode())
|
||||
}
|
||||
|
||||
// FIXME the OS sometimes appears to be using the mount
|
||||
// immediately after it appears so wait a moment
|
||||
|
Loading…
x
Reference in New Issue
Block a user