'Re-read Database from the data in the set location.
This does no locking, with one exception: it will automatically
migrate an index.yaml to an index.json if possible. This requires
taking a write lock.'

def _read(self):

    if os.path.isfile(self._index_path):
        self._read_from_file(self._index_path, format='json')
    elif os.path.isfile(self._old_yaml_index_path):
        if os.access(self._db_dir, (os.R_OK | os.W_OK)):
            self._read_from_file(self._old_yaml_index_path, format='yaml')
            with WriteTransaction(self.lock, timeout=_db_lock_timeout):
                self._write(None, None, None)
        else:
            self._read_from_file(self._old_yaml_index_path, format='yaml')
    else:
        with WriteTransaction(self.lock, timeout=_db_lock_timeout):
            self._write(None, None, None)
        self.reindex(spack.store.layout)
