From 297e5f81c4f69b0140390280c4788edeba5766ef Mon Sep 17 00:00:00 2001 From: Kyle Banker Date: Mon, 25 Jan 2010 13:31:52 -0500 Subject: [PATCH] minor: GridFS fix for 1.9 --- bin/gridstore_benchmark | 1 - lib/mongo/gridfs/grid_store.rb | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) 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