Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
Decrease Memory footprint
Browse files Browse the repository at this point in the history
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
  • Loading branch information
schneems committed May 26, 2015
1 parent f6becd3 commit ce75897
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 7 additions & 1 deletion features/step_definitions/attachment_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ def attachment_path(filename)

Then /^the attachment should have the same content type as the fixture "([^"]*)"$/ do |filename|
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.should == MIME::Types.type_for(filename).first.content_type
end
Expand Down
9 changes: 8 additions & 1 deletion lib/paperclip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,14 @@
require 'paperclip/attachment_registry'
require 'paperclip/filename_cleaner'
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/overlay'
require 'logger'
Expand Down

0 comments on commit ce75897

Please sign in to comment.