aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorFrancis Irving <francis@mysociety.org>2010-03-20 23:24:39 +0000
committerFrancis Irving <francis@mysociety.org>2010-03-20 23:24:39 +0000
commit50c9d4d363c7b57627556efc4c5b8a357c9f209c (patch)
tree16a4750fe451bcdd6942d6050c64bf036825861a /lib
parent6b6f160d7be9055e0ba4ac5c39f03717b08113fa (diff)
If no attachments found in TNEF, that's an error
Diffstat (limited to 'lib')
-rw-r--r--lib/tnef.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/tnef.rb b/lib/tnef.rb
index 2f200e3eb..ff88b0005 100644
--- a/lib/tnef.rb
+++ b/lib/tnef.rb
@@ -19,6 +19,7 @@ class TNEF
raise IOError, "tnef exited with status #{$?.exitstatus}"
end
end
+ found = 0
Dir.new(dir).sort.each do |file| # sort for deterministic behaviour
if file != "." && file != ".."
file_content = File.open("#{dir}/#{file}", "r").read
@@ -26,8 +27,12 @@ class TNEF
attachment['content-location'] = file
attachment.body = file_content
main.parts << attachment
+ found += 1
end
end
+ if found == 0
+ raise IOError, "tnef produced no attachments"
+ end
end
main
end