Allow file provisioner to copy empty folders

This commit is contained in:
sophia 2020-08-05 15:56:04 -05:00
parent 16ef520d9d
commit 187d8e9cfd
2 changed files with 12 additions and 1 deletions

View File

@ -307,10 +307,11 @@ module VagrantPlugins
scp_connect do |scp|
uploader = lambda do |path, remote_dest=nil|
if File.directory?(path)
dest = File.join(to, path.sub(/^#{Regexp.escape(from)}/, ""))
create_remote_directory(dest)
Dir.new(path).each do |entry|
next if entry == "." || entry == ".."
full_path = File.join(path, entry)
dest = File.join(to, path.sub(/^#{Regexp.escape(from)}/, ""))
create_remote_directory(dest)
uploader.call(full_path, dest)
end

View File

@ -565,6 +565,16 @@ describe VagrantPlugins::CommunicatorSSH::Communicator do
end
end
it "creates remote directory given an empty directory" do
file = Dir.mktmpdir
begin
expect(communicator).to receive(:create_remote_directory).with("/destination/dir/#{ File.basename(file)}/")
communicator.upload(file, "/destination/dir")
ensure
FileUtils.rm_rf(file)
end
end
it "raises custom error on permission errors" do
file = Tempfile.new('vagrant-test')
begin