bytesleft = @opts[:maxbytes].andand.to_i || 2**16
IO.popen([env, 'arv-get', "#{@opts[:uuid]}/#{@opts[:file]}"],
'rb') do |io|
- bytecount = 0
- while bytesleft > 0 && buf = io.read(bytesleft)
+ while bytesleft > 0 && (buf = io.read(bytesleft)) != nil
# shrink the bytesleft count, if we were given a
# maximum byte count to read
if @opts.include? :maxbytes