Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1321 from dimko/patch-2

Temp directory overflow issue
  • Loading branch information...
commit 28a4363cf2e5fa208c25334ffb0639db3d8ff8c2 2 parents 91c4cdc + e3d132b
@bensie bensie authored
Showing with 12 additions and 5 deletions.
  1. +12 −5 lib/carrierwave/processing/mini_magick.rb
View
17 lib/carrierwave/processing/mini_magick.rb
@@ -258,12 +258,19 @@ def resize_and_pad(width, height, background=:transparent, gravity='Center')
def manipulate!
cache_stored_file! if !cached?
image = ::MiniMagick::Image.open(current_path)
- image.format(@format.to_s.downcase) if @format
- image = yield(image)
- image.write(current_path)
- ::MiniMagick::Image.open(current_path)
+
+ begin
+ image.format(@format.to_s.downcase) if @format
+ image = yield(image)
+ image.write(current_path)
+ image.run_command("identify", current_path)
+ ensure
+ image.destroy!
+ end
rescue ::MiniMagick::Error, ::MiniMagick::Invalid => e
- raise CarrierWave::ProcessingError, I18n.translate(:"errors.messages.mini_magick_processing_error", :e => e, :default => I18n.translate(:"errors.messages.mini_magick_processing_error", :e => e, :locale => :en))
+ default = I18n.translate(:"errors.messages.mini_magick_processing_error", :e => e, :locale => :en)
+ message = I18n.translate(:"errors.messages.mini_magick_processing_error", :e => e, :default => default)
+ raise CarrierWave::ProcessingError, message
end
end # MiniMagick
Please sign in to comment.
Something went wrong with that request. Please try again.