Skip to content

Commit

Permalink
No timestamp of unprocessable mail to prevent double import of mails.…
Browse files Browse the repository at this point in the history
… Follow up if issue #2092.
  • Loading branch information
zammad-sync committed Oct 8, 2019
1 parent f57f048 commit 886c718
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions app/models/channel/email_parser.rb
Expand Up @@ -488,7 +488,7 @@ def self.process_unprocessable_mails(params = {})
=begin
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
=end
Expand Down Expand Up @@ -796,15 +796,14 @@ def get_attachments(file, attachments, mail)
[attach]
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)
path = Rails.root.join('tmp', folder)
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)
filename = "#{Time.zone.now.iso8601}_#{md5}.eml"
file_path = Rails.root.join('tmp', folder, filename)
file_path = Rails.root.join('tmp', folder, "#{md5}.eml")

File.open(file_path, 'wb') do |file|
file.write msg
Expand Down
2 changes: 1 addition & 1 deletion test/integration/email_postmaster_to_sender.rb
Expand Up @@ -103,7 +103,7 @@ class EmailPostmasterToSender < ActiveSupport::TestCase
# /tmp/oversized_mail/yyyy-mm-ddThh:mm:ss-:md5.eml
path = Rails.root.join('tmp', 'oversized_mail')
target_files = Dir.entries(path).select do |filename|
filename =~ /^.+_#{large_message_md5}\.eml$/
filename =~ /^#{large_message_md5}\.eml$/
end
assert(target_files.present?, 'Large message .eml log file must be present.')

Expand Down

0 comments on commit 886c718

Please sign in to comment.