closes #3990
[arvados.git] / apps / workbench / app / controllers / collections_controller.rb
index e750b2c02d9898562f5fda33028458dd51b725ab..3c6c9d7a8571842ce55fc594b7242e8ce5d193b8 100644 (file)
@@ -325,7 +325,7 @@ class CollectionsController < ApplicationController
 
       bytesleft = @opts[:maxbytes].andand.to_i || 2**16
       io = IO.popen([env, 'arv-get', "#{@opts[:uuid]}/#{@opts[:file]}"], 'rb')
-      while bytesleft > 0 && (buf = io.read(bytesleft)) != nil
+      while bytesleft > 0 && (buf = io.read([bytesleft, 2**16].min)) != nil
         # shrink the bytesleft count, if we were given a maximum byte
         # count to read
         if @opts.include? :maxbytes