lib/mongo/grid/stream/write.rb in mongo-2.2.1 vs lib/mongo/grid/stream/write.rb in mongo-2.2.2

- old
+ new

@@ -80,13 +80,12 @@ # # @since 2.1.0 def write(io) ensure_open! @indexes ||= ensure_indexes! - data = io.read - @length += data.length - chunks = File::Chunk.split(data, file_info, @n) + @length += io.size + chunks = File::Chunk.split(io, file_info, @n) @n += chunks.size chunks_collection.insert_many(chunks) unless chunks.empty? self end @@ -155,13 +154,14 @@ def files_collection with_write_concern(fs.files_collection) end def with_write_concern(collection) - if collection.write_concern.options == write_concern.options + if write_concern.nil? || (collection.write_concern && + collection.write_concern.options == write_concern.options) collection else - collection.client.with(write: write_concern.options)[collection.name] + collection.with(write: write_concern.options) end end def update_length file_info.document[:length] = @length