Merge pull request #6160 from lonniev/lonniev_rsync_issue_6115_branch
Scrub Guest Paths for Windows Rsync leaving Dirty Paths for Winrm Mkdir
This commit is contained in:
commit
7345c67b98
|
@ -2,8 +2,17 @@ module VagrantPlugins
|
|||
module GuestWindows
|
||||
module Cap
|
||||
class RSync
|
||||
def self.rsync_scrub_guestpath( machine, opts )
|
||||
# Windows guests most often use cygwin-dependent rsync utilities
|
||||
# that expect "/cygdrive/c" instead of "c:" as the path prefix
|
||||
# some vagrant code may pass guest paths with drive-lettered paths here
|
||||
opts[:guestpath].gsub( /^([a-zA-Z]):/, '/cygdrive/\1' )
|
||||
end
|
||||
|
||||
def self.rsync_pre(machine, opts)
|
||||
machine.communicate.tap do |comm|
|
||||
# rsync does not construct any gaps in the path to the target directory
|
||||
# make sure that all subdirectories are created
|
||||
comm.execute("mkdir '#{opts[:guestpath]}'")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -64,6 +64,11 @@ module VagrantPlugins
|
|||
Cap::MountSharedFolder
|
||||
end
|
||||
|
||||
guest_capability(:windows, :rsync_scrub_guestpath) do
|
||||
require_relative "cap/rsync"
|
||||
Cap::RSync
|
||||
end
|
||||
|
||||
guest_capability(:windows, :rsync_pre) do
|
||||
require_relative "cap/rsync"
|
||||
Cap::RSync
|
||||
|
|
|
@ -38,6 +38,11 @@ module VagrantPlugins
|
|||
hostpath = File.expand_path(hostpath, machine.env.root_path)
|
||||
hostpath = Vagrant::Util::Platform.fs_real_path(hostpath).to_s
|
||||
|
||||
# if the guest has a guest path scrubber capability, use it
|
||||
if machine.guest.capability?(:rsync_scrub_guestpath)
|
||||
guestpath = machine.guest.capability(:rsync_scrub_guestpath, opts)
|
||||
end
|
||||
|
||||
if Vagrant::Util::Platform.windows?
|
||||
# rsync for Windows expects cygwin style paths, always.
|
||||
hostpath = Vagrant::Util::Platform.cygwin_path(hostpath)
|
||||
|
|
Loading…
Reference in New Issue