Merge pull request #7154 from mitchellh/pr-6316
Create parent directories during ftp push
This commit is contained in:
commit
d9b5e0e97d
|
@ -106,6 +106,7 @@ module VagrantPlugins
|
||||||
def initialize(*)
|
def initialize(*)
|
||||||
require "net/sftp"
|
require "net/sftp"
|
||||||
super
|
super
|
||||||
|
@dirs = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_port
|
def default_port
|
||||||
|
@ -120,7 +121,23 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
def upload(local, remote)
|
def upload(local, remote)
|
||||||
@server.upload!(local, remote, mkdir: true)
|
dir = File.dirname(remote)
|
||||||
|
|
||||||
|
fullpath = Pathname.new(dir)
|
||||||
|
fullpath.descend do |path|
|
||||||
|
if @dirs[path.to_s].nil?
|
||||||
|
begin
|
||||||
|
@server.mkdir!(path.to_s)
|
||||||
|
|
||||||
|
# Cache visited directories in a list to avoid duplicate requests
|
||||||
|
@dirs[path.to_s] = true
|
||||||
|
rescue Net::SFTP::StatusException => e
|
||||||
|
# Directory exists, skip...
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
@server.upload!(local, remote)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue