synced_folders/rsync: convert to proper unix-style path [GH-3086]
This commit is contained in:
parent
59ae11bab3
commit
04a19e05ca
|
@ -50,20 +50,15 @@ module Vagrant
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# This takes any path and converts it to a full-length Windows
|
# This takes any path and converts it from a Windows path to a
|
||||||
# path on Windows machines in Cygwin.
|
# Cygwin or msys style path.
|
||||||
#
|
#
|
||||||
|
# @param [String] path
|
||||||
# @return [String]
|
# @return [String]
|
||||||
def cygwin_windows_path(path, **opts)
|
def cygwin_path(path)
|
||||||
return path if !cygwin? && !opts[:force]
|
|
||||||
|
|
||||||
# First, no matter what process we use below, we must replace
|
|
||||||
# all "\" with "/", otherwise cygpath doesn't work.
|
|
||||||
path = path.gsub("\\", "/")
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
# First try the real cygpath
|
# First try the real cygpath
|
||||||
process = Subprocess.execute("cygpath", "-w", "-l", "-a", path.to_s)
|
process = Subprocess.execute("cygpath", "-u", "-a", path.to_s)
|
||||||
return process.stdout.chomp
|
return process.stdout.chomp
|
||||||
rescue Errors::CommandUnavailableWindows
|
rescue Errors::CommandUnavailableWindows
|
||||||
# Sometimes cygpath isn't available (msys). Instead, do what we
|
# Sometimes cygpath isn't available (msys). Instead, do what we
|
||||||
|
@ -77,6 +72,21 @@ module Vagrant
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# This takes any path and converts it to a full-length Windows
|
||||||
|
# path on Windows machines in Cygwin.
|
||||||
|
#
|
||||||
|
# @return [String]
|
||||||
|
def cygwin_windows_path(path)
|
||||||
|
return path if !cygwin?
|
||||||
|
|
||||||
|
# Replace all "\" with "/", otherwise cygpath doesn't work.
|
||||||
|
path = path.gsub("\\", "/")
|
||||||
|
|
||||||
|
# Call out to cygpath and gather the result
|
||||||
|
process = Subprocess.execute("cygpath", "-w", "-l", "-a", path.to_s)
|
||||||
|
return process.stdout.chomp
|
||||||
|
end
|
||||||
|
|
||||||
# This checks if the filesystem is case sensitive. This is not a
|
# This checks if the filesystem is case sensitive. This is not a
|
||||||
# 100% correct check, since it is possible that the temporary
|
# 100% correct check, since it is possible that the temporary
|
||||||
# directory runs a different filesystem than the root directory.
|
# directory runs a different filesystem than the root directory.
|
||||||
|
|
|
@ -14,9 +14,8 @@ module VagrantPlugins
|
||||||
hostpath = Vagrant::Util::Platform.fs_real_path(hostpath).to_s
|
hostpath = Vagrant::Util::Platform.fs_real_path(hostpath).to_s
|
||||||
|
|
||||||
if Vagrant::Util::Platform.windows?
|
if Vagrant::Util::Platform.windows?
|
||||||
# rsync for Windows expects cygwin style paths
|
# rsync for Windows expects cygwin style paths, always.
|
||||||
hostpath = Vagrant::Util::Platform.cygwin_windows_path(
|
hostpath = Vagrant::Util::Platform.cygwin_path(hostpath)
|
||||||
hostpath, force: true)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Make sure the host path ends with a "/" to avoid creating
|
# Make sure the host path ends with a "/" to avoid creating
|
||||||
|
|
Loading…
Reference in New Issue