Skip to content

Commit d0ff284

Browse files
committed
Skip importing empty file
1 parent dd427fd commit d0ff284

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

app/models/message.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,12 @@ def from_mail(mail, list, list_seq)
9393
class << self
9494
def from_s3(list, list_seq, s3_client = Aws::S3::Client.new(region: BLADE_BUCKET_REGION))
9595
obj = s3_client.get_object(bucket: BLADE_BUCKET_NAME, key: "#{list.name}/#{list_seq}")
96-
mail = Mail.read_from_string obj.body.read.force_encoding(Encoding::BINARY)
96+
str = obj.body.read.force_encoding(Encoding::BINARY)
97+
if str.blank?
98+
p "#{list.name}:#{list_seq} is empty"
99+
return
100+
end
101+
mail = Mail.read_from_string str
97102
Message.from_mail mail, list, list_seq
98103
end
99104

0 commit comments

Comments
 (0)