Always ensure remote destination directory exists
This commit is contained in:
parent
6b105d704d
commit
e2b6a6645c
|
@ -317,10 +317,11 @@ module VagrantPlugins
|
|||
else
|
||||
dest = to
|
||||
if to.end_with?(File::SEPARATOR)
|
||||
create_remote_directory(dest)
|
||||
dest = File.join(to, File.basename(path))
|
||||
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}")
|
||||
upload_file = File.open(path, "rb")
|
||||
begin
|
||||
|
|
|
@ -547,13 +547,24 @@ describe VagrantPlugins::CommunicatorSSH::Communicator do
|
|||
file = Tempfile.new('vagrant-test')
|
||||
begin
|
||||
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/")
|
||||
ensure
|
||||
file.delete
|
||||
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
|
||||
file = Tempfile.new('vagrant-test')
|
||||
begin
|
||||
|
|
Loading…
Reference in New Issue