File tree Expand file tree Collapse file tree 1 file changed +11
-11
lines changed
Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -225,17 +225,17 @@ namespace :cortex do
225225 begin
226226 s3 . get_object ( { bucket :ENV [ 'S3_BUCKET_NAME' ] , key : object_key } , target : media . attachment_file_name )
227227
228- file = File . new media . attachment_file_name
229-
230- puts "Re-saving image attachment #{ media . id } - #{ media . attachment_file_name } "
231- image = file
232- media . attachment = image
233- media . save
234- # if there are multiple styles, you want to recreate them:
235- media . attachment . reprocess!
236-
237- file . close
238- File . delete media . attachment_file_name
228+ image = Tempfile . new media . attachment_file_name
229+ begin
230+ puts "Re-saving image attachment #{ media . id } - #{ media . attachment_file_name } "
231+ media . attachment = image
232+ media . save
233+ # if there are multiple styles, you want to recreate them:
234+ media . attachment . reprocess!
235+ ensure
236+ image . close
237+ image . unlink
238+ end
239239 rescue => ex
240240 puts "An error of type #{ ex . class } occurred, message is #{ ex . message } "
241241 end
You can’t perform that action at this time.
0 commit comments