diff options
author | Seb Bacon <seb@mysociety.org> | 2012-01-09 11:30:48 +0000 |
---|---|---|
committer | Seb Bacon <seb@mysociety.org> | 2012-01-09 11:30:48 +0000 |
commit | 22c2a8ce8c363e53e593128ec2e3f26aa8f259f1 (patch) | |
tree | eaf3ba72aa272b549b4d1544204e4c5eb3e09c55 /app/models/foi_attachment.rb | |
parent | 57cc5eff8b5e3050e3d6a66f7167fc28af329163 (diff) | |
parent | 84190999aa57c5ea6e87f51adadde58d56b22682 (diff) |
Merge branch 'release/0.5' into wdtk
Diffstat (limited to 'app/models/foi_attachment.rb')
-rw-r--r-- | app/models/foi_attachment.rb | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/app/models/foi_attachment.rb b/app/models/foi_attachment.rb index 16e202bee..a14e0b553 100644 --- a/app/models/foi_attachment.rb +++ b/app/models/foi_attachment.rb @@ -1,3 +1,19 @@ +# == Schema Information +# Schema version: 108 +# +# Table name: foi_attachments +# +# id :integer not null, primary key +# content_type :text +# filename :text +# charset :text +# display_size :text +# url_part_number :integer +# within_rfc822_subject :text +# incoming_message_id :integer +# hexdigest :string(32) +# + # encoding: UTF-8 # models/foi_attachment.rb: @@ -47,7 +63,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 |