3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/easy_downloader/sftp.rb', line 3
def sftp_download(options)
Net::SFTP.start(options.host,
options.user,
sftp_password_option(options.password)) do |sftp|
files = sftp.dir.glob(options.remote_path, options.remote_pattern)
options.result.found(files.size, files.map(&:name))
files.map(&:name).each do |path|
options.result.starting_path(path)
options.load_count += 1 if sftp.download!("#{options.remote_path}#{path}", "#{options.local_path}#{path}")
options.result.finished_path(path)
options.result.files_loaded << "#{options.local_path}#{path}"
end
end
end
|