diff options
-rw-r--r-- | spec/spec_helper.rb | 3 | ||||
-rw-r--r-- | vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb | 13 |
2 files changed, 8 insertions, 8 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5c5cd9a7f..fe244c77d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -78,7 +78,6 @@ def load_file_fixture(file_name) end def rebuild_xapian_index(terms = true, values = true, texts = true, dropfirst = true) - parse_all_incoming_messages if dropfirst begin ActsAsXapian.readable_init @@ -86,7 +85,9 @@ def rebuild_xapian_index(terms = true, values = true, texts = true, dropfirst = rescue RuntimeError end ActsAsXapian.writable_init + ActsAsXapian.writable_db.close end + parse_all_incoming_messages verbose = false # safe_rebuild=true, which involves forking to avoid memory leaks, doesn't work well with rspec. # unsafe is significantly faster, and we can afford possible memory leaks while testing. 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 3de31c5c6..5f1456503 100644 --- a/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb +++ b/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb @@ -614,9 +614,6 @@ module ActsAsXapian model.xapian_index(terms, values, texts) end end - # make sure everything is written and closed - ActsAsXapian.writable_db.flush - ActsAsXapian.writable_db.close end # Rename into place @@ -739,9 +736,7 @@ module ActsAsXapian if self.class.xapian_options.include?(:if) if_value = xapian_value(self.class.xapian_options[:if], :boolean) if not if_value - ActsAsXapian.writable_init self.xapian_destroy - ActsAsXapian.writable_db.close return end end @@ -750,7 +745,7 @@ module ActsAsXapian begin ActsAsXapian.readable_init rescue - # ensure we've initialised a writable database + # ensure we've previously initialised a writable database ActsAsXapian.writable_init ActsAsXapian.writable_db.close ActsAsXapian.readable_init @@ -793,7 +788,8 @@ module ActsAsXapian values_to_index = self.xapian_options[:values] end - ActsAsXapian.writable_init + ActsAsXapian.writable_init # now reopen as writable + # clear any existing data that we might want to replace if drop_all_terms && texts # as an optimisation, if we're reindexing all of both, we remove everything @@ -849,7 +845,10 @@ module ActsAsXapian # Delete record from the Xapian database def xapian_destroy + ActsAsXapian.writable_init ActsAsXapian.writable_db.delete_document("I" + self.xapian_document_term) + ActsAsXapian.writable_db.flush + ActsAsXapian.writable_db.close end # Used to mark changes needed by batch indexer |