lib/fastdfs-client/tracker.rb in fastdfs-client-0.0.3 vs lib/fastdfs-client/tracker.rb in fastdfs-client-0.0.5

- old
+ new

@@ -17,18 +17,17 @@ end def get_storage header = ProtoCommon.header_bytes(@cmd, 0) @socket.write(@cmd, header) - @socket.receive do |body| - storage_ip = body[ProtoCommon::IPADDR].strip - storage_port = body[ProtoCommon::PORT].unpack("C*").to_pack_long - store_path = body[ProtoCommon::TRACKER_BODY_LEN-1].unpack("C*")[0] - - Storage.new(storage_ip, storage_port, store_path, options) - end + res = @socket.receive + return res unless res[:status] - + storage_ip = @socket.content[ProtoCommon::IPADDR].strip + storage_port = @socket.content[ProtoCommon::PORT].unpack("C*").to_pack_long + store_path = @socket.content[ProtoCommon::TRACKER_BODY_LEN-1].unpack("C*")[0] + + Storage.new(storage_ip, storage_port, store_path, options) end end end end \ No newline at end of file