         # File lib/ferret/index.rb, line 864
    864:       def ensure_reader_open(get_latest = true)
    865:         raise "tried to use a closed index" if not @open
    866:         if @reader
    867:           if get_latest
    868:             latest = false
    869:             begin
    870:               latest = @reader.latest?
    871:             rescue Lock::LockError => le
    872:               sleep(@options[:lock_retry_time]) # sleep for 2 seconds and try again
    873:               latest = @reader.latest?
    874:             end
    875:             if not latest
    876:               @searcher.close if @searcher
    877:               @reader.close
    878:               return @reader = IndexReader.new(@dir)
    879:             end
    880:           end
    881:         else
    882:           if @writer
    883:             @writer.close
    884:             @writer = nil
    885:           end
    886:           return @reader = IndexReader.new(@dir)
    887:         end
    888:         return false
    889:       end