Sha256: 9511fd8ed8917aecbbc89095b469af17c2d9e96bd19c413a8b75f3dc21e678b0
Contents?: true
Size: 1.27 KB
Versions: 2
Compression:
Stored size: 1.27 KB
Contents
require 'net/ftp' module Ryespy module Listener class FTP def initialize begin @ftp = Net::FTP.new(Ryespy.config.ftp_host) @ftp.passive = Ryespy.config.ftp_passive @ftp.login(Ryespy.config.ftp_username, Ryespy.config.ftp_password) rescue Errno::ECONNREFUSED, Net::FTPError => e Ryespy.logger.error { e.to_s } return end if block_given? yield self close end end def close @ftp.close end def check(params) begin @ftp.chdir(params[:dir]) objects = {} @ftp.nlst.each do |fd| mtime = @ftp.mtime(fd).to_i size = @ftp.size(fd) rescue nil # ignore non-file error if size # exclude directories checksum = "#{mtime},#{size}" if params[:seen_files][fd] != checksum objects[fd] = checksum end end end objects rescue Net::FTPError => e Ryespy.logger.error { e.to_s } return end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ryespy-0.6.1 | lib/ryespy/listeners/ftp.rb |
ryespy-0.6.0 | lib/ryespy/listeners/ftp.rb |