Merge pull request #11880 from elastio/bug/11878-rsync-fails-on-windows

[WIP] Change `mkdir` command on Windows for rsync
This commit is contained in:
Chris Roberts 2021-11-04 15:03:20 -07:00 committed by GitHub
commit f9d1025688
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -13,7 +13,11 @@ module VagrantPlugins
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 -p '#{opts[:guestpath]}'")
# NB: Per #11878, the `mkdir` command on Windows is different than used on Unix.
# This formulation matches the form used in the WinRM communicator plugin.
# This will ignore any -p switches, which are redundant in PowerShell,
# and ambiguous in PowerShell 4+
comm.execute("mkdir \"#{opts[:guestpath]}\" -force")
end
end
end

View File

@ -19,7 +19,7 @@ describe "VagrantPlugins::GuestWindows::Cap::RSync" do
describe ".rsync_pre" do
it 'makes the guestpath directory with mkdir' do
communicator.expect_command("mkdir -p '/sync_dir'")
communicator.expect_command("mkdir \"/sync_dir\" -force")
described_class.rsync_pre(machine, guestpath: '/sync_dir')
end
end