Changeset 286
- Timestamp:
- 04/28/08 02:41:09 (7 months ago)
- Files:
-
- branches/log_indexing_time_with_ferret/lib/picolena/templates/app/models/indexer.rb (modified) (6 diffs)
- branches/log_indexing_time_with_ferret/lib/picolena/templates/config/environment.rb (modified) (1 diff)
- branches/log_indexing_time_with_ferret/lib/picolena/templates/lib/indexing_time.rb (added)
- branches/log_indexing_time_with_ferret/lib/picolena/templates/lib/tasks/install_dependencies.rake (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/log_indexing_time_with_ferret/lib/picolena/templates/app/models/indexer.rb
r283 r286 1 require 'indexing_time' 1 2 class Indexer 2 3 # This regexp defines which files should *not* be indexed. … … 38 39 indexing_list_chunks.each_with_thread{|chunk| 39 40 chunk.each{|complete_path| 40 last_itime=index_time_dbm_file[complete_path] 41 if @from_scratch || !last_itime || File.mtime(complete_path)> Time._load(last_itime) then 41 if @from_scratch || File.mtime(complete_path)> IndexingTime::retrieve(complete_path) then 42 42 add_or_update_file(complete_path) 43 43 else 44 44 log :debug => "Identical : #{complete_path}" 45 45 end 46 index_time_dbm_file[complete_path] = Time.now._dump46 IndexingTime::add(complete_path) 47 47 } 48 48 } … … 73 73 # ensures that a new Index is instantiated next time index is called. 74 74 def close 75 IndexingTime::close_log 75 76 @@index.close rescue nil 76 77 # Ferret will SEGFAULT otherwise. … … 80 81 81 82 # Checks for indexed files that are missing from filesytem 82 # and removes them from index & dbm file.83 # and removes them from indexes. 83 84 def prune_index 84 missing_files=index_time_dbm_file.reject{|filename,itime| File.exists?(filename) && Picolena::IndexedDirectories.any?{|dir,alias_path| filename.starts_with?(dir)}} 85 missing_files.each{|filename, itime| 85 IndexingTime::missing_documents.each{|filename, itime| 86 86 index.writer.delete(:complete_path, filename) 87 index_time_dbm_file.delete(filename)87 IndexingTime::log.delete(filename) 88 88 log :debug => "Removed : #{filename}" 89 89 } 90 90 index.optimize 91 IndexingTime::log.optimize 91 92 end 92 93 … … 108 109 109 110 private 110 111 # Copied from Ferret book, By David Balmain112 def index_time_dbm_file113 @@dbm_file ||= DBM.open(File.join(Picolena::IndexSavePath, 'added_at'))114 end115 116 111 def index_exists? 117 112 index_filename and File.exists?(index_filename) … … 157 152 # Ferret::Store::Lock::LockError 158 153 index 159 # Opens dbm file to dump indexing time.160 index_time_dbm_file154 # Opens another index, to log IndexingTime of every document. 155 IndexingTime::log 161 156 # ActiveSupport sometime raises 162 157 # Expected Object is NOT missing constant branches/log_indexing_time_with_ferret/lib/picolena/templates/config/environment.rb
r280 r286 1 %w(rubygems paginator fileutils pathname logger thread dbm).each{|lib| require lib}1 %w(rubygems paginator fileutils pathname logger thread).each{|lib| require lib} 2 2 3 3 # Uncomment below to force Rails into production mode when branches/log_indexing_time_with_ferret/lib/picolena/templates/lib/tasks/install_dependencies.rake
r280 r286 31 31 root_privileges_required! 32 32 #TODO: Should load this list from defined PlainTextExtractor's 33 packages=%w{antiword poppler-utils odt2txt html2text catdoc unrtf mguesser libdbm-ruby1.8}.join(" ")33 packages=%w{antiword poppler-utils odt2txt html2text catdoc unrtf mguesser}.join(" ") 34 34 puts "Installing "<<packages 35 35 system("apt-get install "<<packages)
