Changeset 280

Show
Ignore:
Timestamp:
04/26/08 08:29:38 (7 months ago)
Author:
eric.dumin..@gmail.com
Message:

rake index:update implemented with dbm support. (as in David Balmain's book)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/History.txt

    r277 r280  
    33* 1 minor enhancement: 
    44  * added cache highlighting à la Google 
     5  * rake index:update implemented as described in Ferret book by David Balmain 
    56 
    67== 0.1.6  2008-04-25 
  • trunk/lib/picolena/templates/app/models/indexer.rb

    r267 r280  
    1111      @@do_not_disturb_while_indexing=true 
    1212      clear! if remove_first 
     13      @from_scratch = remove_first 
    1314      # Forces Finder.searcher and Finder.index to be reloaded, by removing them from the cache. 
    1415      Finder.reload! 
     
    3637       
    3738      indexing_list_chunks.each_with_thread{|chunk| 
    38         chunk.each{|filename| 
    39           add_file(filename) 
     39        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 
     42            add_or_update_file(complete_path) 
     43          else 
     44            log :debug => "Identical : #{complete_path}" 
     45          end 
     46          index_time_dbm_file[complete_path] = Time.now._dump 
    4047        } 
    4148      } 
    4249    end 
    4350 
    44     def add_file(complete_path) 
     51    def add_or_update_file(complete_path) 
    4552      default_fields = Document.default_fields_for(complete_path) 
    4653      begin 
     
    8794 
    8895    private 
     96     
     97    # Copied from Ferret book, By David Balmain 
     98    def index_time_dbm_file 
     99      @@dbm_file ||= DBM.open(File.join(Picolena::IndexSavePath, 'added_at')) 
     100    end 
    89101 
    90102    def index_exists? 
     
    131143      #  Ferret::Store::Lock::LockError 
    132144      index 
     145      # Opens dbm file to dump indexing time. 
     146      index_time_dbm_file 
    133147      # NOTE: is it really necessary? 
    134148      # ActiveSupport sometime raises 
  • trunk/lib/picolena/templates/config/environment.rb

    r263 r280  
    1 %w(rubygems paginator fileutils pathname logger thread).each{|lib| require lib} 
     1%w(rubygems paginator fileutils pathname logger thread dbm).each{|lib| require lib} 
    22 
    33# Uncomment below to force Rails into production mode when 
  • trunk/lib/picolena/templates/lib/tasks/install_dependencies.rake

    r263 r280  
    3131    root_privileges_required! 
    3232    #TODO: Should load this list from defined PlainTextExtractor's 
    33     packages=%w{antiword poppler-utils odt2txt html2text catdoc unrtf mguesser}.join(" ") 
     33    packages=%w{antiword poppler-utils odt2txt html2text catdoc unrtf mguesser libdbm-ruby1.8}.join(" ") 
    3434    puts "Installing "<<packages 
    3535    system("apt-get install "<<packages)