-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 1.1.4
-
Component/s: None
-
Labels:None
As of the Ruby mongo-1.1.4 gem, GridIO#read_all is defined as:
- Read a file in its entirety.
def read_all
buf = ''
while true
buf << @current_chunk['data'].to_s
@current_chunk = get_chunk(@current_chunk['n'] + 1)
break unless @current_chunk
end
buf
end
The shortcut of setting @current_chunk = get_chunk(next_n) has a side effect of breaking anything that depends on @current_chunk. read_length handles this properly, though it may be a few more instructions than is required when doing a read_all.
WORKAROUND:
Using GridIO#read_length(file_length_or_remaining_length) doesn't break further seeks, etc.