Пример #1
0
    def delete_old(self, old_build_path):
        """Delete all indices and catalog entries of old format."""

        # A sleep loop around deleting the old build dir. It can take a few
        # seconds for the web servers to restart and relinquish their holds on
        # the shared libs in the old virtualenv. Until that happens, NFS
        # creates .nfs* files in the dir that get in the way of deletion.
        for duration in [1, 5, 10, 30]:
            try:
                rmtree_if_exists(old_build_path)  # doesn't resolve symlinks
            except OSError as exc:
                sleep(duration)
            else:
                break

        if self._format_changed_from:
            # Loop over the trees, get the alias of each, and delete:
            for tree in self._trees_of_version(self._format_changed_from):
                # Do one at a time, because it could be more than a URL's
                # max length, assuming netty has one.
                current_app.es.delete_index(tree['_source']['es_alias'])

                # Delete as we go in case we fail partway through. Then at
                # least we can come back with `dxr delete` and clean up.
                current_app.es.delete(self.config.es_catalog_index,
                                      TREE,
                                      tree['_id'])
Пример #2
0
    def delete_old(self, old_build_path):
        """Delete all indices and catalog entries of old format."""

        # A sleep loop around deleting the old build dir. It can take a few
        # seconds for the web servers to restart and relinquish their holds on
        # the shared libs in the old virtualenv. Until that happens, NFS
        # creates .nfs* files in the dir that get in the way of deletion.
        for duration in [1, 5, 10, 30]:
            try:
                rmtree_if_exists(old_build_path)  # doesn't resolve symlinks
            except OSError as exc:
                sleep(duration)
            else:
                break

        if self._format_changed_from:
            # Loop over the trees, get the alias of each, and delete:
            for tree in self._trees_of_version(self._format_changed_from):
                # Do one at a time, because it could be more than a URL's
                # max length, assuming netty has one.
                current_app.es.delete_index(tree['_source']['es_alias'])

                # Delete as we go in case we fail partway through. Then at
                # least we can come back with `dxr delete` and clean up.
                current_app.es.delete(self.config.es_catalog_index,
                                      TREE,
                                      tree['_id'])
Пример #3
0
def clean(config, tree_names):
    """Remove logs, temp files, and build artifacts.

    Remove the filesystem debris left after indexing one or more TREES, leaving
    the index itself intact. Delete log files and, if present, temp files. Run
    `make clean` (or other clean_command from the config file) on trees.

    """
    for tree in tree_objects(tree_names, config):
        rmtree_if_exists(tree.log_folder)
        rmtree_if_exists(tree.temp_folder)
        chdir(tree.object_folder)
        if tree.clean_command:
            try:
                run(tree.clean_command)
            except CommandFailure as exc:
                raise ClickException(
                    'Running clean_command failed for "%s" tree: %s.' %
                    (tree.name, str(exc)))