aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/raw_email.rb
diff options
context:
space:
mode:
authorSeb Bacon <seb.bacon@gmail.com>2012-06-27 14:15:09 +0100
committerSeb Bacon <seb.bacon@gmail.com>2012-06-27 14:15:09 +0100
commitaf24b1e306dab3ebe10d97f7777abedd011321da (patch)
treeb440b839bf1e7465ab154cdc19ee9366b9f98198 /app/models/raw_email.rb
parent6c4c822ef7a4491bf821326af779e5be9118c0a1 (diff)
parent5b80d1b9a0933b1e20de013d1aa8b8522f2ad066 (diff)
Merge branch 'release/0.6.1'0.6.1
Diffstat (limited to 'app/models/raw_email.rb')
-rw-r--r--app/models/raw_email.rb15
1 files changed, 9 insertions, 6 deletions
diff --git a/app/models/raw_email.rb b/app/models/raw_email.rb
index 1466e5d9c..3bb794684 100644
--- a/app/models/raw_email.rb
+++ b/app/models/raw_email.rb
@@ -19,13 +19,12 @@ class RawEmail < ActiveRecord::Base
has_one :incoming_message
- # We keep the old data_text field (which is of type text) for backwards
- # compatibility. We use the new data_binary field because only it works
- # properly in recent versions of PostgreSQL (get seg faults escaping
- # some binary strings).
-
def directory
request_id = self.incoming_message.info_request.id.to_s
+ if request_id.empty?
+ raise "Failed to find the id number of the associated request: has it been saved?"
+ end
+
if ENV["RAILS_ENV"] == "test"
return File.join(Rails.root, 'files/raw_email_test')
else
@@ -36,7 +35,11 @@ class RawEmail < ActiveRecord::Base
end
def filepath
- File.join(self.directory, self.incoming_message.id.to_s)
+ incoming_message_id = self.incoming_message.id.to_s
+ if incoming_message_id.empty?
+ raise "Failed to find the id number of the associated incoming message: has it been saved?"
+ end
+ File.join(self.directory, incoming_message_id)
end
def data=(d)