From ca3cb385d4b4ab957805a3fe08ef70844b57cbcf Mon Sep 17 00:00:00 2001 From: wucheng Date: Thu, 2 Apr 2015 14:44:11 +0800 Subject: [PATCH] fix ftp push check bug list method is not safe to check if a dir exist or not on remote. --- plugins/pushes/ftp/adapter.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/pushes/ftp/adapter.rb b/plugins/pushes/ftp/adapter.rb index 8a9414376..b4c4f48f2 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? + unless check_dir_exists? path.to_s @server.mkdir(path.to_s) end end @@ -83,6 +83,15 @@ module VagrantPlugins @server.putbinaryfile(local, remote) end + def check_dir_exists?(path) + begin + @server.chdir(path) + return true + rescue Net::FTPPermError + return false + end + end + private def pwd