Skip to content

Commit

Permalink
Decrease Fog 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 d7b18dd commit 83493b9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/carrierwave/processing/mime_types.rb
Expand Up @@ -29,6 +29,9 @@ module MimeTypes
included do
CarrierWave::Utilities::Deprecation.new "0.11.0", "CarrierWave::MimeTypes is deprecated and will be removed in the future, get the content_type from the SanitizedFile object directly."
begin
# Use mime/types/columnar if available, for reduced memory usage
require 'mime/types/columnar'
rescue LoadError
require "mime/types"
rescue LoadError => e
e.message << " (You may need to install the mime-types gem)"
Expand Down
8 changes: 7 additions & 1 deletion lib/carrierwave/sanitized_file.rb
Expand Up @@ -2,7 +2,13 @@

require 'pathname'
require 'active_support/core_ext/string/multibyte'
require 'mime/types'

begin
# Use mime/types/columnar if available, for reduced memory usage
require 'mime/types/columnar'
rescue LoadError
require 'mime/types'
end

module CarrierWave

Expand Down
8 changes: 7 additions & 1 deletion spec/sanitized_file_spec.rb
@@ -1,7 +1,13 @@
# encoding: utf-8

require 'spec_helper'
require 'mime/types'

begin
# Use mime/types/columnar if available, for reduced memory usage
require 'mime/types/columnar'
rescue LoadError
require 'mime/types'
end

describe CarrierWave::SanitizedFile do

Expand Down

0 comments on commit 83493b9

Please sign in to comment.