diff options
-rw-r--r-- | app/controllers/request_controller.rb | 1 | ||||
-rw-r--r-- | app/models/info_request.rb | 1 | ||||
-rw-r--r-- | app/models/request_mailer.rb | 13 | ||||
-rw-r--r-- | config/httpd.conf | 1 | ||||
-rw-r--r-- | spec/lib/tmail_extensions_spec.rb | 5 | ||||
-rw-r--r-- | vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb | 42 | ||||
-rw-r--r-- | vendor/plugins/acts_as_xapian/lib/tasks/xapian.rake | 1 |
7 files changed, 54 insertions, 10 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 99aa3c7ea..fbf862af3 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -607,6 +607,7 @@ class RequestController < ApplicationController else incoming_message = IncomingMessage.find(params[:incoming_message_id]) if !incoming_message.info_request.user_can_view?(authenticated_user) + @info_request = incoming_message.info_request # used by view render :template => 'request/hidden', :status => 410 # gone end end diff --git a/app/models/info_request.rb b/app/models/info_request.rb index a0652ecd8..b5a1cd833 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -21,7 +21,6 @@ require 'digest/sha1' -require File.join(File.dirname(__FILE__),'../../vendor/plugins/acts_as_xapian/lib/acts_as_xapian') class InfoRequest < ActiveRecord::Base strip_attributes! diff --git a/app/models/request_mailer.rb b/app/models/request_mailer.rb index 272f2ea83..83cce9045 100644 --- a/app/models/request_mailer.rb +++ b/app/models/request_mailer.rb @@ -353,7 +353,18 @@ class RequestMailer < ApplicationMailer # That that patch has not been applied, despite bribes of beer, is # typical of the lack of quality of Rails. - info_requests = InfoRequest.find(:all, :conditions => [ "(select id from info_request_events where event_type = 'comment' and info_request_events.info_request_id = info_requests.id and created_at > ? limit 1) is not null", Time.now() - 1.month ], :include => [ { :info_request_events => :user_info_request_sent_alerts } ], :order => "info_requests.id, info_request_events.created_at" ) + info_requests = InfoRequest.find(:all, + :conditions => [ + "info_requests.id in ( + select info_request_id + from info_request_events + where event_type = 'comment' + and created_at > (now() - '1 month'::interval) + )" + ], + :include => [ { :info_request_events => :user_info_request_sent_alerts } ], + :order => "info_requests.id, info_request_events.created_at" + ) for info_request in info_requests # Count number of new comments to alert on diff --git a/config/httpd.conf b/config/httpd.conf index 14197d8e4..3bbe50fb3 100644 --- a/config/httpd.conf +++ b/config/httpd.conf @@ -38,6 +38,7 @@ RewriteRule /files/(.+) http://files.whatdotheyknow.com/$1 PassengerResolveSymlinksInDocumentRoot on # Recommend setting this to 3 or less on servers with 512MB RAM PassengerMaxPoolSize 6 + RailsEnv production </IfModule> # Gzip font resources diff --git a/spec/lib/tmail_extensions_spec.rb b/spec/lib/tmail_extensions_spec.rb index 6a55c34da..02ef8b82e 100644 --- a/spec/lib/tmail_extensions_spec.rb +++ b/spec/lib/tmail_extensions_spec.rb @@ -5,6 +5,11 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe "when using TMail" do + fixtures :info_requests, :incoming_messages + + before(:each) do + ActionMailer::Base.deliveries.clear + end it "should load an email with funny MIME settings" do # just send it to the holding pen diff --git a/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb b/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb index 70605ad04..1c7ff97b0 100644 --- a/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb +++ b/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb @@ -30,14 +30,19 @@ module ActsAsXapian class NoXapianRubyBindingsError < StandardError end - # XXX global class intializers here get loaded more than once, don't know why. Protect them. - if not $acts_as_xapian_class_var_init - @@db = nil - @@db_path = nil - @@writable_db = nil - @@init_values = [] + @@db = nil + @@db_path = nil + @@writable_db = nil + @@init_values = [] + + # There used to be a problem with this module being loaded more than once. + # Keep a check here, so we can tell if the problem recurs. + if $acts_as_xapian_class_var_init + raise "The acts_as_xapian module has already been loaded" + else $acts_as_xapian_class_var_init = true end + def ActsAsXapian.db @@db end @@ -248,6 +253,8 @@ module ActsAsXapian end end + MSET_MAX_TRIES = 5 + MSET_MAX_DELAY = 5 # Set self.query before calling this def initialize_query(options) #raise options.to_yaml @@ -278,7 +285,28 @@ module ActsAsXapian ActsAsXapian.enquire.collapse_key = value end - self.matches = ActsAsXapian.enquire.mset(offset, limit, 100) + tries = 0 + delay = 1 + begin + self.matches = ActsAsXapian.enquire.mset(offset, limit, 100) + rescue IOError => e + if e.message =~ /DatabaseModifiedError: / + # This should be a transient error, so back off and try again, up to a point + if tries > MAX_TRIES + raise "Received DatabaseModifiedError from Xapian even after retrying #{MAX_TRIES} times" + else + sleep delay + end + tries += 1 + delay *= 2 + delay = MAX_DELAY if delay > MAX_DELAY + + @@db.reopen() + retry + else + raise + end + end self.cached_results = nil } end diff --git a/vendor/plugins/acts_as_xapian/lib/tasks/xapian.rake b/vendor/plugins/acts_as_xapian/lib/tasks/xapian.rake index 470016420..c1986ce1e 100644 --- a/vendor/plugins/acts_as_xapian/lib/tasks/xapian.rake +++ b/vendor/plugins/acts_as_xapian/lib/tasks/xapian.rake @@ -2,7 +2,6 @@ require 'rubygems' require 'rake' require 'rake/testtask' require 'active_record' -require File.dirname(__FILE__) + '/../acts_as_xapian.rb' namespace :xapian do # Parameters - specify "flush=true" to save changes to the Xapian database |