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

Decrease Memory footprint #1873

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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