class Geminabox::Server

def reindex(force_rebuild = false)

def reindex(force_rebuild = false)
  fixup_bundler_rubygems!
  force_rebuild = true unless Geminabox.incremental_updates
  if force_rebuild
    indexer.generate_index
    dependency_cache.flush
  else
    begin
      require 'geminabox/indexer'
      updated_gemspecs = Geminabox::Indexer.updated_gemspecs(indexer)
      return if updated_gemspecs.empty?
      indexer.update_index
      updated_gemspecs.each { |gem| dependency_cache.flush_key(gem.name) }
    rescue Errno::ENOENT
      with_rlock { reindex(:force_rebuild) }
    rescue => e
      puts "#{e.class}:#{e.message}"
      puts e.backtrace.join("\n")
      with_rlock { reindex(:force_rebuild) }
    end
  end
rescue Gem::SystemExitException
end