Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Don't recreate files if already present

  • Loading branch information...
commit 9d01084e2e101fc2a01fc699a021bd3b8d4c9859 1 parent 67061ab
@davidcornu authored
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/letter_opener/message.rb
View
4 lib/letter_opener/message.rb
@@ -26,7 +26,9 @@ def render
FileUtils.mkdir_p(attachments_dir)
mail.attachments.each do |attachment|
path = File.join(attachments_dir, attachment.filename)
- File.open(path, 'wb') { |f| f.write(attachment.body.raw_source) }
+ unless File.exists?(path) # true if other parts have already been rendered
+ File.open(path, 'wb') { |f| f.write(attachment.body.raw_source) }
+ end
@attachments << [attachment.filename, "attachments/#{URI.escape(attachment.filename)}"]
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.