Changeset 265
- Timestamp:
- 04/25/08 07:28:51 (7 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/picolena/templates/app/controllers/documents_controller.rb
r263 r265 8 8 9 9 class DocumentsController < ApplicationController 10 before_filter :ensure_index_is_created, :except=> :index 10 11 before_filter :check_if_valid_link, :only=> [:download, :content, :cached] 11 12 … … 59 60 @document=Document.find_by_unique_id(@probably_unique_id) rescue no_valid_link 60 61 end 62 63 def ensure_index_is_created 64 Indexer.ensure_index_existence 65 while Indexer.do_not_disturb_while_indexing do 66 sleep 1 67 end 68 end 61 69 62 70 # Flashes a warning and redirects to documents_url. trunk/lib/picolena/templates/app/models/indexer.rb
r263 r265 4 4 # Number of threads that will be used during indexing process 5 5 @@max_threads_number = 8 6 7 cattr_reader :do_not_disturb_while_indexing 6 8 7 9 class << self 8 10 def index_every_directory(remove_first=false) 11 @@do_not_disturb_while_indexing=true 9 12 clear! if remove_first 10 13 # Forces Finder.searcher and Finder.index to be reloaded, by removing them from the cache. … … 17 20 log :debug => "Now optimizing index" 18 21 index.optimize 22 @@do_not_disturb_while_indexing=false 19 23 log :debug => "Indexing done in #{Time.now-start} s." 20 24 end … … 28 32 29 33 indexing_list_chunks=indexing_list.in_transposed_slices(@@max_threads_number) 30 31 # It initializes the Index before launching multithreaded 32 # indexing. Otherwise, two threads could try to instantiate 33 # an IndexWriter at the same time, and get a 34 # Ferret::Store::Lock::LockError 35 index 36 34 35 prepare_multi_threads_environment 36 37 37 indexing_list_chunks.each_with_thread{|chunk| 38 38 chunk.each{|filename| … … 124 124 end 125 125 end 126 127 def prepare_multi_threads_environment 128 # It initializes the Index before launching multithreaded 129 # indexing. Otherwise, two threads could try to instantiate 130 # an IndexWriter at the same time, and get a 131 # Ferret::Store::Lock::LockError 132 index 133 # NOTE: is it really necessary? 134 # ActiveSupport sometime raises 135 # Expected Object is NOT missing constant 136 # without. 137 Document 138 Finder 139 Query 140 PlainTextExtractor 141 end 126 142 end 127 143 end
