         # File lib/ferret/index.rb, line 704
    704:       def ensure_reader_open(get_latest = true)
    705:         raise "tried to use a closed index" if not @open
    706:         if @reader
    707:           if get_latest
    708:             latest = false
    709:             begin
    710:               latest = @reader.latest?
    711:             rescue Lock::LockError => le
    712:               sleep(@options[:lock_retry_time]) # sleep for 2 seconds and try again
    713:               latest = @reader.latest?
    714:             end
    715:             if not latest
    716:               @searcher.close if @searcher
    717:               @reader.close
    718:               return @reader = IndexReader.new(@dir)
    719:             end
    720:           end
    721:         else
    722:           if @writer
    723:             @writer.close
    724:             @writer = nil
    725:           end
    726:           return @reader = IndexReader.new(@dir)
    727:         end
    728:         return false
    729:       end