ftp_sync 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -21,4 +21,6 @@ make some changes on server
21
21
  ftp.pull_dir '/tmp/syncdir', 'path/on/server', :since => true, :delete => true
22
22
 
23
23
  :since => true - means only files which are newer than the local copy will be downloaded
24
+ :since => Time.now - means only files which are newer than the supplied date will be downloaded
24
25
  :delete => true - means if the file is removed from the server, then the local copy is removed
26
+ :skip_errors => true - means if file cant be read (ie permissions) it will be skipped
data/lib/ftp_sync.rb CHANGED
@@ -66,8 +66,13 @@ class FtpSync
66
66
  tocopy.each do |paths|
67
67
  localfile, remotefile = paths
68
68
  unless should_ignore?(localfile)
69
- @connection.get(remotefile, localfile)
70
- log "Pulled file #{remotefile}"
69
+ begin
70
+ @connection.get(remotefile, localfile)
71
+ log "Pulled file #{remotefile}"
72
+ rescue Net::FTPPermError
73
+ log "ERROR READING #{remotefile}"
74
+ raise Net::FTPPermError unless options[:skip_errors]
75
+ end
71
76
  end
72
77
  end
73
78
 
@@ -125,6 +125,26 @@ class FtpSyncTest < Test::Unit::TestCase
125
125
  FileUtils.rm_r File.join(Net::FTP.ftp_src, 'README')
126
126
  @ftp.pull_dir(@local, '/')
127
127
  assert File.exist?(File.join(@local, 'README'))
128
+ end
129
+
130
+ def test_pulling_with_permissions_error_fails
131
+ FileUtils.chmod 0200, File.join(Net::FTP.ftp_src, 'fileA')
132
+ assert_raises Net::FTPPermError do
133
+ @ftp.pull_dir(@local, '/')
134
+ end
135
+ assert File.exist?(File.join(@local, 'README'))
136
+ assert !File.exist?(File.join(@local, 'fileA'))
137
+ assert !File.exist?(File.join(@local, 'fileB'))
138
+ end
139
+
140
+ def test_pulling_with_permissions_error_continues
141
+ FileUtils.chmod 0200, File.join(Net::FTP.ftp_src, 'fileA')
142
+ assert_nothing_raised do
143
+ @ftp.pull_dir(@local, '/', :skip_errors => true)
144
+ end
145
+ assert File.exist?(File.join(@local, 'README'))
146
+ assert !File.exist?(File.join(@local, 'fileA'))
147
+ assert File.exist?(File.join(@local, 'fileB'))
128
148
  end
129
149
 
130
150
  def test_quick_pull_of_file_older_than_change_date
data/test/net/ftp.rb CHANGED
@@ -61,7 +61,10 @@ module Net
61
61
 
62
62
  def get(src, dst)
63
63
  raise Net::FTPPermError unless File.exist?(src_path(src))
64
+ File.read(src_path(src))
64
65
  FileUtils.cp src_path(src), dst
66
+ rescue Errno::EACCES
67
+ raise Net::FTPPermError
65
68
  end
66
69
 
67
70
  def put(src, dst)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ftp_sync
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 1
10
- version: 0.4.1
9
+ - 2
10
+ version: 0.4.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - jebw
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-12 00:00:00 +01:00
18
+ date: 2010-11-30 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency