minor: GridFS fix for 1.9

This commit is contained in:
Kyle Banker 2010-01-25 13:31:52 -05:00
parent 9070c57922
commit 297e5f81c4
2 changed files with 4 additions and 1 deletions

View File

@ -1,7 +1,6 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
require 'rubygems' require 'rubygems'
require 'mongo' require 'mongo'
require 'mongo/gridfs'
#require 'ruby-prof' #require 'ruby-prof'
include Mongo include Mongo

View File

@ -392,6 +392,10 @@ module GridFS
def write(string) def write(string)
raise "#@filename not opened for write" unless @mode[0] == ?w raise "#@filename not opened for write" unless @mode[0] == ?w
# Since Ruby 1.9.1 doesn't necessarily store one character per byte.
if string.respond_to?(:force_encoding)
string.force_encoding("binary")
end
to_write = string.length to_write = string.length
while (to_write > 0) do while (to_write > 0) do
if @curr_chunk && @curr_chunk.data.position == @chunk_size if @curr_chunk && @curr_chunk.data.position == @chunk_size