diff --git a/lib/ftp_sync.rb b/lib/ftp_sync.rb index ddb0afa..524c342 100644 --- a/lib/ftp_sync.rb +++ b/lib/ftp_sync.rb @@ -41,10 +41,6 @@ def pull_dir(localpath, remotepath, options = {}, &block) tocopy = [] recurse = [] - # To trigger error if path doesnt exist since list will - # just return and empty array - @connection.chdir(remotepath) - @connection.list(remotepath) do |e| entry = Net::FTP::List.parse(e) diff --git a/test/ftp_sync_test.rb b/test/ftp_sync_test.rb index d994c6a..9b0c066 100644 --- a/test/ftp_sync_test.rb +++ b/test/ftp_sync_test.rb @@ -109,8 +109,15 @@ def test_pull_dir_from_subdir assert File.exist?(File.join(@local, 'fileAA')) assert File.exist?(File.join(@local, 'dirAA/fileAAA')) end - + + def test_pull_dir_from_relative_dir + @ftp.pull_dir(@local, 'dirA') + assert File.exist?(File.join(@local, 'fileAA')) + assert File.exist?(File.join(@local, 'dirAA/fileAAA')) + end + def test_pull_dir_from_nonexistant_dir + omit "need a fix that doesn't break relative paths" assert_raise Net::FTPPermError do @ftp.pull_dir(@local, 'something') end diff --git a/test/net/ftp.rb b/test/net/ftp.rb index d8fb311..09d796a 100644 --- a/test/net/ftp.rb +++ b/test/net/ftp.rb @@ -81,7 +81,8 @@ def mkdir(dir) end def chdir(dir) - raise Net::FTPPermError unless File.exist?(src_path(dir)) + self.ftp_src = src_path(dir) + raise Net::FTPPermError unless File.exist?(ftp_src) end def list(dir)