1
mirror of https://github.com/rclone/rclone synced 2024-11-08 05:31:41 +01:00

mount: improved handling of relative paths on windows

This commit is contained in:
albertony 2021-02-08 17:25:59 +01:00 committed by Nick Craig-Wood
parent b39fa54ab2
commit cc5a1e90d8

View File

@ -114,11 +114,12 @@ func handleLocalMountpath(mountpath string, opt *mountlib.Options) (string, erro
fs.Errorf(nil, "Ignoring --network-mode as it is not supported with directory mountpoint")
opt.NetworkMode = false
}
parent := filepath.Join(mountpath, "..")
if parent == "" || parent == "." {
return "", errors.New("mountpoint parent path is not valid: " + parent)
var err error
if mountpath, err = filepath.Abs(mountpath); err != nil { // Ensures parent is found but also more informative log messages
return "", errors.Wrap(err, "mountpoint path is not valid: "+mountpath)
}
if _, err := os.Stat(parent); err != nil {
parent := filepath.Join(mountpath, "..")
if _, err = os.Stat(parent); err != nil {
if os.IsNotExist(err) {
return "", errors.New("parent of mountpoint directory does not exist: " + parent)
}