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
This commit is contained in:
Nick Craig-Wood 2020-03-07 16:32:37 +00:00
parent 26001d520a
commit 0ee16b51c4

View file

@ -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
if !hasOption("uid") {
options = append(options, "-o", "uid=-1")
}
if !hasOption("gid") {
options = append(options, "-o", "gid=-1")
}
options = append(options, "--FileSystemName=rclone")
}