From 9d1753cabe819c5ce37986fcca8d6cca1dc19eba Mon Sep 17 00:00:00 2001 From: trent Date: Wed, 20 Feb 2013 13:06:57 -0500 Subject: [PATCH 1/2] remove ftp.chdir, breaks relative paths, and doesnt do anything --- lib/ftp_sync.rb | 4 ---- 1 file changed, 4 deletions(-) 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) From 5ecad552a4cd34050e6113360b0a0adb2e5de29b Mon Sep 17 00:00:00 2001 From: Scott Bronson Date: Mon, 21 Mar 2016 15:14:46 -0700 Subject: [PATCH 2/2] make test harness support chdir, omit broken test Ensures test_pull_dir_from_nonexistant_dir behaves like real life --- test/ftp_sync_test.rb | 9 ++++++++- test/net/ftp.rb | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) 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)