# File lib/rubytorrent/metainfo.rb, line 57 def initialize(dict=nil) @s = TypedStruct.new do |s| s.field :length => Integer, :md5sum => String, :name => String, :piece_length => Integer, :pieces => String, :files => MetaInfoInfoFile, :sha1 => String s.label :piece_length => "piece length" s.required :name, :piece_length, :pieces s.array :files s.coerce :files => lambda { |x| x.map { |y| MetaInfoInfoFile.new(y) } } end @dict = dict unless dict.nil? @s.parse dict check if dict["sha1"] ## this seems to always be off. don't know how it's supposed ## to be calculated, so fuck it. # puts "we have #{sha1.inspect}, they have #{dict['sha1'].inspect}" # rt_warning "info hash SHA1 mismatch" unless dict["sha1"] == sha1 # raise MetaInfoFormatError, "info hash SHA1 mismatch" unless dict["sha1"] == sha1 end end end