mirror of https://github.com/rclone/rclone.git
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)
|
- fs - a remote path to be mounted (required)
|
||||||
- mountPoint: valid path on the local machine (required)
|
- mountPoint: valid path on the local machine (required)
|
||||||
- mountType: One of the values (mount, cmount, mount2) specifies the mount implementation to use
|
- mountType: One of the values (mount, cmount, mount2) specifies the mount implementation to use
|
||||||
|
- vfsOpt: a JSON object with VFS options in.
|
||||||
|
|
||||||
Eg
|
Eg
|
||||||
|
|
||||||
rclone rc mount/mount fs=mydrive: mountPoint=/home/<user>/mountPoint
|
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=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
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vfsOpt := vfsflags.Opt
|
||||||
|
err = in.GetStructMissingOK("vfsOpt", &vfsOpt)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
mountType, err := in.GetString("mountType")
|
mountType, err := in.GetString("mountType")
|
||||||
|
|
||||||
mountMu.Lock()
|
mountMu.Lock()
|
||||||
|
@ -93,7 +106,7 @@ func mountRc(_ context.Context, in rc.Params) (out rc.Params, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if mountFns[mountType] != nil {
|
if mountFns[mountType] != nil {
|
||||||
VFS := vfs.New(fdst, &vfsflags.Opt)
|
VFS := vfs.New(fdst, &vfsOpt)
|
||||||
_, unmountFn, err := mountFns[mountType](VFS, mountPoint)
|
_, unmountFn, err := mountFns[mountType](VFS, mountPoint)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -68,6 +68,9 @@ func TestRc(t *testing.T) {
|
||||||
in := rc.Params{
|
in := rc.Params{
|
||||||
"fs": localDir,
|
"fs": localDir,
|
||||||
"mountPoint": mountPoint,
|
"mountPoint": mountPoint,
|
||||||
|
"vfsOpt": rc.Params{
|
||||||
|
"FilePerms": 0400,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// check file.txt is not there
|
// check file.txt is not there
|
||||||
|
@ -86,6 +89,9 @@ func TestRc(t *testing.T) {
|
||||||
fi, err := os.Stat(filePath)
|
fi, err := os.Stat(filePath)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, int64(5), fi.Size())
|
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
|
// FIXME the OS sometimes appears to be using the mount
|
||||||
// immediately after it appears so wait a moment
|
// immediately after it appears so wait a moment
|
||||||
|
|
Loading…
Reference in New Issue