diff --git a/cmd/cmount/arch.go b/cmd/cmount/arch.go new file mode 100644 index 000000000..b6503b246 --- /dev/null +++ b/cmd/cmount/arch.go @@ -0,0 +1,7 @@ +package cmount + +// ProvidedBy returns true if the rclone build for the given OS +// provides support for lib/cgo-fuse +func ProvidedBy(osName string) bool { + return osName == "windows" || osName == "darwin" +} diff --git a/cmd/cmount/mount.go b/cmd/cmount/mount.go index 94f1084fd..d9c21edf6 100644 --- a/cmd/cmount/mount.go +++ b/cmd/cmount/mount.go @@ -26,7 +26,7 @@ import ( func init() { name := "cmount" - cmountOnly := runtime.GOOS == "windows" || runtime.GOOS == "darwin" + cmountOnly := ProvidedBy(runtime.GOOS) if cmountOnly { name = "mount" } diff --git a/cmd/selfupdate/help.go b/cmd/selfupdate/help.go index 71783f896..73fcdb45f 100644 --- a/cmd/selfupdate/help.go +++ b/cmd/selfupdate/help.go @@ -37,6 +37,10 @@ your OS) to update these too. This command with the default |--package zip| will update only the rclone executable so the local manual may become inaccurate after it. +The |rclone mount| command (https://rclone.org/commands/rclone_mount/) may +or may not support extended FUSE options depending on the build and OS. +|selfupdate| will refuse to update if the capability would be discarded. + Note: Windows forbids deletion of a currently running executable so this command will rename the old executable to 'rclone.old.exe' upon success. diff --git a/cmd/selfupdate/selfupdate.go b/cmd/selfupdate/selfupdate.go index 822cb7a09..3e2988935 100644 --- a/cmd/selfupdate/selfupdate.go +++ b/cmd/selfupdate/selfupdate.go @@ -21,9 +21,11 @@ import ( "github.com/pkg/errors" "github.com/rclone/rclone/cmd" + "github.com/rclone/rclone/cmd/cmount" "github.com/rclone/rclone/fs" "github.com/rclone/rclone/fs/config/flags" "github.com/rclone/rclone/fs/fshttp" + "github.com/rclone/rclone/lib/buildinfo" "github.com/rclone/rclone/lib/random" "github.com/spf13/cobra" @@ -141,6 +143,17 @@ func InstallUpdate(ctx context.Context, opt *Options) error { return errors.New("--stable and --beta are mutually exclusive") } + gotCmount := false + for _, tag := range buildinfo.Tags { + if tag == "cmount" { + gotCmount = true + break + } + } + if gotCmount && !cmount.ProvidedBy(runtime.GOOS) { + return errors.New("updating would discard the mount FUSE capability, aborting") + } + newVersion, siteURL, err := GetVersion(ctx, opt.Beta, opt.Version) if err != nil { return errors.Wrap(err, "unable to detect new version")