Merge pull request #11805 from soapy1/file-provisioner-copy-empty-folder

Allow file provisioner to copy empty folders
This commit is contained in:
Sophia Castellarin 2020-08-06 15:58:34 -05:00 committed by GitHub
commit 1f92d3617d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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