diff options
-rw-r--r-- | app/views/general/blog.html.erb | 2 | ||||
-rw-r--r-- | lib/tasks/temp.rake | 22 | ||||
-rw-r--r-- | spec/models/incoming_message_spec.rb | 4 |
3 files changed, 27 insertions, 1 deletions
diff --git a/app/views/general/blog.html.erb b/app/views/general/blog.html.erb index 7146aab5d..ef587421e 100644 --- a/app/views/general/blog.html.erb +++ b/app/views/general/blog.html.erb @@ -23,7 +23,7 @@ <% @blog_items.each do |item| %> <div class="blog_post"> <h2 id="<%= Time.parse(item['pubDate'][0]).to_i %>"><a href="<%=item['link'][0]%>"><%=h item['title'][0] %></a></h2> - <p class="subtitle"><%= _("Posted on {{date}} by {{author}}", :date=>simple_date(Time.parse(item['pubDate'][0])), :author=>item['creator'][0]) %></p> + <p class="subtitle"><%= _("Posted on {{date}} by {{author}}", :date=>simple_date(Time.parse(item['pubDate'][0])), :author=> item['creator'] ? item['creator'][0] : item['author'][0]) %></p> <div> <% if item['encoded'] %> <%= raw item['encoded'][0] %> diff --git a/lib/tasks/temp.rake b/lib/tasks/temp.rake index 35ae442c7..fcabb23de 100644 --- a/lib/tasks/temp.rake +++ b/lib/tasks/temp.rake @@ -7,6 +7,28 @@ namespace :temp do user.save! unless dryrun end + desc "Re-extract any missing cached attachments" + task :reextract_missing_attachments, [:commit] => :environment do |t, args| + dry_run = args.commit.nil? || args.commit.empty? + total_messages = 0 + messages_to_reparse = 0 + IncomingMessage.find_each :include => :foi_attachments do |im| + reparse = im.foi_attachments.any? { |fa| ! File.exists? fa.filepath } + total_messages += 1 + messages_to_reparse += 1 if reparse + if total_messages % 1000 == 0 + puts "Considered #{total_messages} received emails." + end + unless dry_run + im.parse_raw_email! true if reparse + sleep 2 + end + end + message = dry_run ? "Would reparse" : "Reparsed" + message += " #{messages_to_reparse} out of #{total_messages} received emails." + puts message + end + desc 'Cleanup accounts with a space in the email address' task :clean_up_emails_with_spaces => :environment do dryrun = ENV['DRYRUN'] == '0' ? false : true diff --git a/spec/models/incoming_message_spec.rb b/spec/models/incoming_message_spec.rb index 03152f5ff..76d7eba2e 100644 --- a/spec/models/incoming_message_spec.rb +++ b/spec/models/incoming_message_spec.rb @@ -544,6 +544,10 @@ end describe IncomingMessage, "when extracting attachments" do + before do + load_raw_emails_data + end + it 'handles the case where reparsing changes the body of the main part and the cached attachment has been deleted' do # original set of attachment attributes |