Skip to content

Commit

Permalink
Merge pull request #1985 from obduk/close_file
Browse files Browse the repository at this point in the history
Close file in SanitizedFile#mime_magic_content_type
  • Loading branch information
mshibuya committed Aug 13, 2016
2 parents fa5dd61 + f6d65dd commit 2d6f958
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/carrierwave/sanitized_file.rb
Expand Up @@ -315,7 +315,11 @@ def existing_content_type
end

def mime_magic_content_type
MimeMagic.by_magic(File.open(path)).try(:type) if path
if path
File.open(path) do |file|
MimeMagic.by_magic(file).try(:type)
end
end
rescue Errno::ENOENT
nil
end
Expand Down

0 comments on commit 2d6f958

Please sign in to comment.