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
225
225
begin
226
226
s3 . get_object ( { bucket :ENV [ 'S3_BUCKET_NAME' ] , key : object_key } , target : media . attachment_file_name )
227
227
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
239
239
rescue => ex
240
240
puts "An error of type #{ ex . class } occurred, message is #{ ex . message } "
241
241
end
You can’t perform that action at this time.
0 commit comments