aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfrancis <francis>2008-09-13 12:13:04 +0000
committerfrancis <francis>2008-09-13 12:13:04 +0000
commit785cc46732d451b2e3fa3815477fc23ba7e1c562 (patch)
tree141965b03cfcb1cad26fef9a521557029e50305d
parent5458be30029f4f381adde4a8d11e2bee4a154b76 (diff)
Fix from github
-rw-r--r--vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb7
1 files changed, 7 insertions, 0 deletions
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 bcefc7ad4..8670830bc 100644
--- a/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb
+++ b/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb
@@ -454,6 +454,13 @@ module ActsAsXapian
# make sure that each index update is definitely saved to disk before
# logging in the database that it has been.
def ActsAsXapian.update_index(flush = false, verbose = false)
+ # Before calling writable_init we have to make sure every model class has been initialized.
+ # i.e. has had its class code loaded, so acts_as_xapian has been called inside it, and
+ # we have the info from acts_as_xapian.
+ model_classes = ActsAsXapianJob.find_by_sql("select model from acts_as_xapian_jobs group by model").map {|a| a.model.constantize}
+ # If there are no models in the queue, then nothing to do
+ return if model_classes.size == 0
+
ActsAsXapian.writable_init
ids_to_refresh = ActsAsXapianJob.find(:all).map() { |i| i.id }