diff --git a/CHANGELOG.md b/CHANGELOG.md index 979ad1cf6..dcb3f8ff8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ BUG FIXES: - provisioners/chef-zero: support more chef-zero/local mode attributes [GH-5339] - provisioners/docker: use docker.com instead of docker.io [GH-5216] - pushes/atlas: send additional box metadata [GH-5283] + - pushes/ftp: improve check for remote directory existence [GH-5549] - synced\_folders/rsync: add `IdentitiesOnly=yes` to the rsync command. [GH-5175] - virtualbox/config: fix misleading error message for private_network [GH-5536, GH-5418] diff --git a/plugins/pushes/ftp/adapter.rb b/plugins/pushes/ftp/adapter.rb index 8a9414376..d0d076491 100644 --- a/plugins/pushes/ftp/adapter.rb +++ b/plugins/pushes/ftp/adapter.rb @@ -74,7 +74,7 @@ module VagrantPlugins # Create the parent directories if they does not exist (naive mkdir -p) fullpath.descend do |path| - if @server.list(path.to_s).empty? + if !directory_exists?(path.to_s) @server.mkdir(path.to_s) end end @@ -83,6 +83,15 @@ module VagrantPlugins @server.putbinaryfile(local, remote) end + def directory_exists?(path) + begin + @server.chdir(path) + return true + rescue Net::FTPPermError + return false + end + end + private def pwd