match the chunk size in the 10gen mongo driver to solve connection issues when saving large files, and get tests working again
This commit is contained in:
parent
6fb6677a1e
commit
66b8afe0d6
@ -58,6 +58,8 @@
|
|||||||
#
|
#
|
||||||
module Mongoid
|
module Mongoid
|
||||||
class GridFS
|
class GridFS
|
||||||
|
DEFAULT_CHUNK_SIZE = 256 * 1024
|
||||||
|
|
||||||
class << GridFS
|
class << GridFS
|
||||||
attr_accessor :namespace
|
attr_accessor :namespace
|
||||||
attr_accessor :file_model
|
attr_accessor :file_model
|
||||||
@ -293,7 +295,7 @@
|
|||||||
field(:contentType, :type => String, :default => 'application/octet-stream')
|
field(:contentType, :type => String, :default => 'application/octet-stream')
|
||||||
|
|
||||||
field(:length, :type => Integer, :default => 0)
|
field(:length, :type => Integer, :default => 0)
|
||||||
field(:chunkSize, :type => Integer, :default => (256 * (2 ** 20)))
|
field(:chunkSize, :type => Integer, :default => DEFAULT_CHUNK_SIZE)
|
||||||
field(:uploadDate, :type => Date, :default => Time.now.utc)
|
field(:uploadDate, :type => Date, :default => Time.now.utc)
|
||||||
field(:md5, :type => String, :default => Digest::MD5.hexdigest(''))
|
field(:md5, :type => String, :default => Digest::MD5.hexdigest(''))
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
require 'pp'
|
require 'pp'
|
||||||
require_relative 'testing'
|
require_relative 'testing'
|
||||||
require_relative '../lib/mongoid-sequence.rb'
|
require_relative '../lib/mongoid-sequence.rb'
|
||||||
|
require_relative '../lib/mongoid-grid_fs.rb'
|
||||||
|
|
||||||
Mongoid.configure do |config|
|
Mongoid.configure do |config|
|
||||||
config.connect_to('mongoid-sequence')
|
config.connect_to('mongoid-sequence')
|
||||||
|
@ -70,7 +70,7 @@ Testing Mongoid::GridFs do
|
|||||||
path = 'a.rb'
|
path = 'a.rb'
|
||||||
data = IO.read(__FILE__)
|
data = IO.read(__FILE__)
|
||||||
|
|
||||||
sio = SIO.new(path, data)
|
sio = StringIO.new(data)
|
||||||
|
|
||||||
g = assert{ GridFs[path] = sio and GridFs[path] }
|
g = assert{ GridFs[path] = sio and GridFs[path] }
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ Testing Mongoid::GridFs do
|
|||||||
|
|
||||||
before = GridFs::File.count
|
before = GridFs::File.count
|
||||||
|
|
||||||
assert{ GridFs[path] = SIO.new(path, 'foobar') }
|
assert{ GridFs[path] = StringIO.new('foobar') }
|
||||||
assert{ GridFs[path].data == 'foobar' }
|
assert{ GridFs[path].data == 'foobar' }
|
||||||
|
|
||||||
after = GridFs::File.count
|
after = GridFs::File.count
|
||||||
|
Loading…
Reference in New Issue
Block a user