diff --git a/bin/gridstore_benchmark b/bin/gridstore_benchmark index 120b5de..49c3e2f 100755 --- a/bin/gridstore_benchmark +++ b/bin/gridstore_benchmark @@ -1,7 +1,6 @@ #!/usr/bin/env ruby require 'rubygems' require 'mongo' -require 'mongo/gridfs' #require 'ruby-prof' include Mongo diff --git a/lib/mongo/gridfs/grid_store.rb b/lib/mongo/gridfs/grid_store.rb index c9c4110..dc419a6 100644 --- a/lib/mongo/gridfs/grid_store.rb +++ b/lib/mongo/gridfs/grid_store.rb @@ -392,6 +392,10 @@ module GridFS def write(string) 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 while (to_write > 0) do if @curr_chunk && @curr_chunk.data.position == @chunk_size