fix: reading chunks from an empty (zero-length) grid-stored file

reading chunks from an empty file caused an endless loop
This commit is contained in:
Daniël van de Burgt 2011-05-10 22:58:50 -05:00
parent 3cb1e4644b
commit 6e66b11f6e
1 changed files with 2 additions and 1 deletions

View File

@ -251,8 +251,9 @@ module Mongo
# @return [Mongo::GridIO] self
def each
return read_all unless block_given?
while chunk = read(chunk_size)
while chunk = read(chunk_size)
yield chunk
break if chunk.empty?
end
self
end