From 6ffb1c98c4c8afb5fd01425180c00b4ce3dbe16d Mon Sep 17 00:00:00 2001 From: Thomas Sinclair Date: Thu, 25 Mar 2021 10:49:59 +1100 Subject: [PATCH] Removed mimemagic and falling back to file due to incompatible mimemagic licence --- NEWS | 4 ++++ lib/paperclip.rb | 2 -- lib/paperclip/content_type_detector.rb | 7 +------ lib/paperclip/version.rb | 2 +- paperclip.gemspec | 1 - 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/NEWS b/NEWS index 0b4b031a0..5f69c2e54 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +4.3.8 (25/3/2021): + +* Removed mimemagic dependency due to newly incompatible licence + 4.3.7 (7/1/2016): * Add deprecation warnings diff --git a/lib/paperclip.rb b/lib/paperclip.rb index de883e118..11c9a9997 100644 --- a/lib/paperclip.rb +++ b/lib/paperclip.rb @@ -65,8 +65,6 @@ require "mime/types" end -require 'mimemagic' -require 'mimemagic/overlay' require 'logger' require 'cocaine' diff --git a/lib/paperclip/content_type_detector.rb b/lib/paperclip/content_type_detector.rb index 782ed9e7c..9868823f1 100644 --- a/lib/paperclip/content_type_detector.rb +++ b/lib/paperclip/content_type_detector.rb @@ -60,17 +60,12 @@ def possible_types end def type_from_file_contents - type_from_mime_magic || type_from_file_command + type_from_file_command rescue Errno::ENOENT => e Paperclip.log("Error while determining content type: #{e}") SENSIBLE_DEFAULT end - def type_from_mime_magic - @type_from_mime_magic ||= - MimeMagic.by_magic(File.open(@filepath)).try(:type) - end - def type_from_file_command @type_from_file_command ||= FileCommandContentTypeDetector.new(@filepath).detect diff --git a/lib/paperclip/version.rb b/lib/paperclip/version.rb index 4e39e076c..4ff0d36e5 100644 --- a/lib/paperclip/version.rb +++ b/lib/paperclip/version.rb @@ -1,3 +1,3 @@ module Paperclip - VERSION = "4.3.7".freeze unless defined? Paperclip::VERSION + VERSION = "4.3.6".freeze unless defined? Paperclip::VERSION end diff --git a/paperclip.gemspec b/paperclip.gemspec index 4aa4421c2..bd5b0573d 100644 --- a/paperclip.gemspec +++ b/paperclip.gemspec @@ -24,7 +24,6 @@ Gem::Specification.new do |s| s.add_dependency('activesupport', '>= 3.2.0') s.add_dependency('cocaine', '~> 0.5.5') s.add_dependency('mime-types') - s.add_dependency('mimemagic', '0.3.0') s.add_development_dependency('activerecord', '>= 3.2.0') s.add_development_dependency('shoulda')