No timestamp of unprocessable mail to prevent double import of mails. Follow up if issue #2092.

This commit is contained in:
Martin Edenhofer 2019-10-08 09:19:04 +02:00
parent f57f0486a3
commit 886c718e12
2 changed files with 5 additions and 6 deletions

View file

@ -488,7 +488,7 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again
=begin =begin
process oversized emails by: process oversized emails by:
1. Archiving the oversized mail as tmp/oversized_mail/timestamp_md5.eml 1. Archiving the oversized mail as tmp/oversized_mail/md5.eml
2. Reply with a postmaster message to inform the sender 2. Reply with a postmaster message to inform the sender
=end =end
@ -796,15 +796,14 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again
[attach] [attach]
end end
# Archive the given message as tmp/folder/timestamp_md5.eml # Archive the given message as tmp/folder/md5.eml
def archive_mail(folder, msg) def archive_mail(folder, msg)
path = Rails.root.join('tmp', folder) path = Rails.root.join('tmp', folder)
FileUtils.mkpath path FileUtils.mkpath path
# MD5 hash the msg and save it as "timestamp_md5.eml" # MD5 hash the msg and save it as "md5.eml"
md5 = Digest::MD5.hexdigest(msg) md5 = Digest::MD5.hexdigest(msg)
filename = "#{Time.zone.now.iso8601}_#{md5}.eml" file_path = Rails.root.join('tmp', folder, "#{md5}.eml")
file_path = Rails.root.join('tmp', folder, filename)
File.open(file_path, 'wb') do |file| File.open(file_path, 'wb') do |file|
file.write msg file.write msg

View file

@ -103,7 +103,7 @@ Oversized Email Message Body #{'#' * 120_000}
# /tmp/oversized_mail/yyyy-mm-ddThh:mm:ss-:md5.eml # /tmp/oversized_mail/yyyy-mm-ddThh:mm:ss-:md5.eml
path = Rails.root.join('tmp', 'oversized_mail') path = Rails.root.join('tmp', 'oversized_mail')
target_files = Dir.entries(path).select do |filename| target_files = Dir.entries(path).select do |filename|
filename =~ /^.+_#{large_message_md5}\.eml$/ filename =~ /^#{large_message_md5}\.eml$/
end end
assert(target_files.present?, 'Large message .eml log file must be present.') assert(target_files.present?, 'Large message .eml log file must be present.')