'Populates the user_directory from the current state of the DB, used
when synapse first starts with user_directory support'

@defer.inlineCallbacks
def _do_initial_spam(self):

    new_pos = (yield self.store.get_max_stream_id_in_current_state_deltas())
    (yield self.store.delete_all_from_user_dir())
    room_ids = (yield self.store.get_all_rooms())
    logger.info('Doing    initial    update    of    user    directory.    %d    rooms', len(room_ids))
    num_processed_rooms = 1
    for room_id in room_ids:
        logger.info('Handling    room    %d/%d', num_processed_rooms, len(room_ids))
        (yield self._handle_intial_room(room_id))
        num_processed_rooms += 1
        (yield sleep((self.INITIAL_SLEEP_MS / 1000.0)))
    logger.info('Processed    all    rooms.')
    self.initially_handled_users = None
    self.initially_handled_users_in_public = None
    self.initially_handled_users_share = None
    self.initially_handled_users_share_private_room = None
    (yield self.store.update_user_directory_stream_pos(new_pos))
