aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeb Bacon <seb.bacon@gmail.com>2012-01-09 11:02:54 +0000
committerSeb Bacon <seb.bacon@gmail.com>2012-01-09 11:02:54 +0000
commitcaff0a3ff2e38a5aab906baa4cc77d30587e1184 (patch)
tree7a2b3396a3e659d81e2b8af36c40ca7029f46b16
parentf9bf86f10d9cbcfb8d4e7e1ea676fc4bbe28134d (diff)
Ensure we regenerate cache if for some reason it's missing
-rw-r--r--app/models/foi_attachment.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/app/models/foi_attachment.rb b/app/models/foi_attachment.rb
index 16e202bee..1f06907f1 100644
--- a/app/models/foi_attachment.rb
+++ b/app/models/foi_attachment.rb
@@ -47,7 +47,13 @@ class FoiAttachment < ActiveRecord::Base
def body
if @cached_body.nil?
- @cached_body = File.open(self.filepath, "rb" ).read
+ begin
+ @cached_body = File.open(self.filepath, "rb" ).read
+ rescue Errno::ENOENT
+ # we've lost our cached attachments for some reason. Reparse them.
+ force = true
+ self.incoming_message.parse_raw_email!(force)
+ end
end
return @cached_body
end