Skip to content

Commit 6e66b11

Browse files
author
Daniël van de Burgt
committed
fix: reading chunks from an empty (zero-length) grid-stored file
reading chunks from an empty file caused an endless loop
1 parent 3cb1e46 commit 6e66b11

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/mongo/gridfs/grid_io.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,9 @@ def close
251251
# @return [Mongo::GridIO] self
252252
def each
253253
return read_all unless block_given?
254-
while chunk = read(chunk_size)
254+
while chunk = read(chunk_size)
255255
yield chunk
256+
break if chunk.empty?
256257
end
257258
self
258259
end

0 commit comments

Comments
 (0)