From 0ee16b51c4deb22783a215c42305659e99b6a3be Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sat, 7 Mar 2020 16:32:37 +0000 Subject: [PATCH] mount: On Windows don't add -o uid/gid=-1 if user supplies -o uid/gid. Before this change if the user supplied `-o uid=XXX` then rclone would write `-o uid=-1 -o uid=XXX` so duplicating the uid value. After this change rclone doesn't write the default `-1` version. This fix affects `uid` and `gid`. See: https://forum.rclone.org/t/issue-with-rclone-mount-and-resilio-sync/14730/27 --- cmd/cmount/mount.go | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/cmd/cmount/mount.go b/cmd/cmount/mount.go index ebda4dcd9..50c755985 100644 --- a/cmd/cmount/mount.go +++ b/cmd/cmount/mount.go @@ -12,6 +12,7 @@ import ( "fmt" "os" "runtime" + "strings" "time" "github.com/billziss-gh/cgofuse/fuse" @@ -58,11 +59,26 @@ func mountOptions(VFS *vfs.VFS, device string, mountpoint string, opt *mountlib. } } + // determine if ExtraOptions already has an opt in + hasOption := func(optionName string) bool { + optionName += "=" + for _, option := range opt.ExtraOptions { + if strings.HasPrefix(option, optionName) { + return true + } + } + return false + } + // Windows options if runtime.GOOS == "windows" { // These cause WinFsp to mean the current user - options = append(options, "-o", "uid=-1") - options = append(options, "-o", "gid=-1") + if !hasOption("uid") { + options = append(options, "-o", "uid=-1") + } + if !hasOption("gid") { + options = append(options, "-o", "gid=-1") + } options = append(options, "--FileSystemName=rclone") }