Commit 14356d7e by schneems Committed by Tute Costa

Decrease Memory footprint

Mime-types 2.6.1+ has a columnar store that only loads the data that is
needed for a drastically reduced memory footprint.
cc/ @jeremyevans @halostatue

See: https://github.com/mime-types/ruby-mime-types/pull/96.

[fixes #1873]
parent ec4ec30d
...@@ -49,7 +49,13 @@ end ...@@ -49,7 +49,13 @@ end
Then /^the attachment should have the same content type as the fixture "([^"]*)"$/ do |filename| Then /^the attachment should have the same content type as the fixture "([^"]*)"$/ do |filename|
in_current_dir do in_current_dir do
require 'mime/types' begin
# Use mime/types/columnar if available, for reduced memory usage
require "mime/types/columnar"
rescue LoadError
require "mime/types"
end
attachment_content_type = `bundle exec #{runner_command} "puts User.last.attachment_content_type"`.strip attachment_content_type = `bundle exec #{runner_command} "puts User.last.attachment_content_type"`.strip
attachment_content_type.should == MIME::Types.type_for(filename).first.content_type attachment_content_type.should == MIME::Types.type_for(filename).first.content_type
end end
......
...@@ -56,7 +56,14 @@ require 'paperclip/has_attached_file' ...@@ -56,7 +56,14 @@ require 'paperclip/has_attached_file'
require 'paperclip/attachment_registry' require 'paperclip/attachment_registry'
require 'paperclip/filename_cleaner' require 'paperclip/filename_cleaner'
require 'paperclip/rails_environment' require 'paperclip/rails_environment'
require 'mime/types'
begin
# Use mime/types/columnar if available, for reduced memory usage
require "mime/types/columnar"
rescue LoadError
require "mime/types"
end
require 'mimemagic' require 'mimemagic'
require 'mimemagic/overlay' require 'mimemagic/overlay'
require 'logger' require 'logger'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment