Parent

Methods

Files

MogileFS::NewFile::ContentRange

an IO-like object

Attributes

md5[R]

Public Instance Methods

hit(uri, req) click to toggle source
# File lib/mogilefs/new_file/content_range.rb, line 10
def hit(uri, req)
  @opts[:nhp_put].request(uri, req).value
end
write(buf) click to toggle source

see IO#write

# File lib/mogilefs/new_file/content_range.rb, line 49
def write(buf)
  buf = String buf
  len = buf.bytesize
  return 0 if 0 == len

  devid, uri = get_dest
  put = request_for(uri, buf)
  begin
    hit(uri, put) # raises on error
  rescue => e
    raise if @bytes_uploaded > 0

    # nothing uploaded, try another dest
    @errors << "#{uri.to_s} - #{e.message} (#{e.class})"
    devid, uri = get_dest
    put = request_for(uri, buf)
    retry
  end

  @uri, @devid = uri, devid if 0 == @bytes_uploaded
  @bytes_uploaded += len
  len
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.