module MogileFS::PathsSize
Public Class Methods
call(paths)
click to toggle source
# File lib/mogilefs/paths_size.rb, line 5 def self.call(paths) errors = {} paths.each do |path| uri = URI.parse(path) begin case r = Net::HTTP.start(uri.host, uri.port) { |x| x.head(uri.path) } when Net::HTTPOK return r['Content-Length'.freeze].to_i else errors[path] = r end rescue => err errors[path] = err end end errors = errors.map { |path,err| "#{path} - #{err.message} (#{err.class})" } raise MogileFS::Error, "all paths failed with HEAD: #{errors.join(', ')}" end