Always ensure remote destination directory exists
This commit is contained in:
parent
6b105d704d
commit
e2b6a6645c
|
@ -317,10 +317,11 @@ module VagrantPlugins
|
||||||
else
|
else
|
||||||
dest = to
|
dest = to
|
||||||
if to.end_with?(File::SEPARATOR)
|
if to.end_with?(File::SEPARATOR)
|
||||||
create_remote_directory(dest)
|
|
||||||
dest = File.join(to, File.basename(path))
|
dest = File.join(to, File.basename(path))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@logger.debug("Ensuring remote directory exists for destination upload")
|
||||||
|
create_remote_directory(File.dirname(dest))
|
||||||
@logger.debug("Uploading file #{path} to remote #{dest}")
|
@logger.debug("Uploading file #{path} to remote #{dest}")
|
||||||
upload_file = File.open(path, "rb")
|
upload_file = File.open(path, "rb")
|
||||||
begin
|
begin
|
||||||
|
|
|
@ -547,13 +547,24 @@ describe VagrantPlugins::CommunicatorSSH::Communicator do
|
||||||
file = Tempfile.new('vagrant-test')
|
file = Tempfile.new('vagrant-test')
|
||||||
begin
|
begin
|
||||||
expect(scp).to receive(:upload!).with(instance_of(File), "/destination/dir/#{File.basename(file.path)}")
|
expect(scp).to receive(:upload!).with(instance_of(File), "/destination/dir/#{File.basename(file.path)}")
|
||||||
expect(communicator).to receive(:create_remote_directory).with("/destination/dir/")
|
expect(communicator).to receive(:create_remote_directory).with("/destination/dir")
|
||||||
communicator.upload(file.path, "/destination/dir/")
|
communicator.upload(file.path, "/destination/dir/")
|
||||||
ensure
|
ensure
|
||||||
file.delete
|
file.delete
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "creates remote directory path to destination on upload" do
|
||||||
|
file = Tempfile.new('vagrant-test')
|
||||||
|
begin
|
||||||
|
expect(scp).to receive(:upload!).with(instance_of(File), "/destination/dir/file.txt")
|
||||||
|
expect(communicator).to receive(:create_remote_directory).with("/destination/dir")
|
||||||
|
communicator.upload(file.path, "/destination/dir/file.txt")
|
||||||
|
ensure
|
||||||
|
file.delete
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it "raises custom error on permission errors" do
|
it "raises custom error on permission errors" do
|
||||||
file = Tempfile.new('vagrant-test')
|
file = Tempfile.new('vagrant-test')
|
||||||
begin
|
begin
|
||||||
|
|
Loading…
Reference in New Issue