mirror of
https://github.com/rclone/rclone.git
synced 2024-11-21 16:03:29 +01:00
nfsmount: fix stale handle problem after converting options to new style
This problem was caused by the defaults not being set for the options
after the conversion to the new config system in
28ba4b832d
serve nfs: convert options to new style
This makes the nfs serve options globally available so nfsmount can
use them directly.
Fixes #8029
This commit is contained in:
parent
3bb6d0a42b
commit
a365503750
@ -21,8 +21,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
sudo = false
|
||||
nfsServerOpt nfs.Options
|
||||
sudo = false
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -33,11 +32,11 @@ func init() {
|
||||
mountlib.AddRc(name, mount)
|
||||
cmdFlags := cmd.Flags()
|
||||
flags.BoolVarP(cmdFlags, &sudo, "sudo", "", sudo, "Use sudo to run the mount/umount commands as root.", "")
|
||||
nfs.AddFlags(cmdFlags, &nfsServerOpt)
|
||||
nfs.AddFlags(cmdFlags)
|
||||
}
|
||||
|
||||
func mount(VFS *vfs.VFS, mountpoint string, opt *mountlib.Options) (asyncerrors <-chan error, unmount func() error, err error) {
|
||||
s, err := nfs.NewServer(context.Background(), VFS, &nfsServerOpt)
|
||||
s, err := nfs.NewServer(context.Background(), VFS, &nfs.Opt)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"github.com/rclone/rclone/cmd/serve/nfs"
|
||||
"github.com/rclone/rclone/vfs/vfscommon"
|
||||
"github.com/rclone/rclone/vfs/vfstest"
|
||||
"github.com/stretchr/testify/require"
|
||||
@ -29,7 +30,7 @@ func TestMount(t *testing.T) {
|
||||
}
|
||||
sudo = true
|
||||
}
|
||||
nfsServerOpt.HandleCacheDir = t.TempDir()
|
||||
require.NoError(t, nfsServerOpt.HandleCache.Set("disk"))
|
||||
nfs.Opt.HandleCacheDir = t.TempDir()
|
||||
require.NoError(t, nfs.Opt.HandleCache.Set("disk"))
|
||||
vfstest.RunTests(t, false, vfscommon.CacheModeWrites, false, mount)
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ var OptionsInfo = fs.Options{{
|
||||
}}
|
||||
|
||||
func init() {
|
||||
fs.RegisterGlobalOptions(fs.OptionsInfo{Name: "nfs", Opt: &opt, Options: OptionsInfo})
|
||||
fs.RegisterGlobalOptions(fs.OptionsInfo{Name: "nfs", Opt: &Opt, Options: OptionsInfo})
|
||||
}
|
||||
|
||||
type handleCache = fs.Enum[handleCacheChoices]
|
||||
@ -72,16 +72,17 @@ type Options struct {
|
||||
HandleCacheDir string `config:"nfs_cache_dir"` // where the handle cache should be stored
|
||||
}
|
||||
|
||||
var opt Options
|
||||
// Opt is the default set of serve nfs options
|
||||
var Opt Options
|
||||
|
||||
// AddFlags adds flags for serve nfs (and nfsmount)
|
||||
func AddFlags(flagSet *pflag.FlagSet, Opt *Options) {
|
||||
func AddFlags(flagSet *pflag.FlagSet) {
|
||||
flags.AddFlagsFromOptions(flagSet, "", OptionsInfo)
|
||||
}
|
||||
|
||||
func init() {
|
||||
vfsflags.AddFlags(Command.Flags())
|
||||
AddFlags(Command.Flags(), &opt)
|
||||
AddFlags(Command.Flags())
|
||||
}
|
||||
|
||||
// Run the command
|
||||
@ -90,7 +91,7 @@ func Run(command *cobra.Command, args []string) {
|
||||
cmd.CheckArgs(1, 1, command, args)
|
||||
f = cmd.NewFsSrc(args)
|
||||
cmd.Run(false, true, command, func() error {
|
||||
s, err := NewServer(context.Background(), vfs.New(f, &vfscommon.Opt), &opt)
|
||||
s, err := NewServer(context.Background(), vfs.New(f, &vfscommon.Opt), &Opt)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user