         # File lib/ferret/index.rb, line 714
    714:       def ensure_reader_open(get_latest = true)
    715:         raise "tried to use a closed index" if not @open
    716:         if @reader
    717:           if get_latest
    718:             latest = false
    719:             begin
    720:               latest = @reader.latest?
    721:             rescue Lock::LockError => le
    722:               sleep(@options[:lock_retry_time]) # sleep for 2 seconds and try again
    723:               latest = @reader.latest?
    724:             end
    725:             if not latest
    726:               @searcher.close if @searcher
    727:               @reader.close
    728:               return @reader = IndexReader.new(@dir)
    729:             end
    730:           end
    731:         else
    732:           if @writer
    733:             @writer.close
    734:             @writer = nil
    735:           end
    736:           return @reader = IndexReader.new(@dir)
    737:         end
    738:         return false
    739:       end