Example #1
0
    def prune_source_infos(self):
        """Remove all source infos of files that no longer exist."""
        MAX_VARS = 999  # Default SQLITE_MAX_VARIABLE_NUMBER.
        con = self.connect_to_database()
        to_clean = []
        try:
            cur = con.cursor()
            cur.execute('''
                select distinct source from source_info
            ''')
            for source, in cur.fetchall():
                fs_path = os.path.join(self.env.root_path, source)
                if not os.path.exists(fs_path):
                    to_clean.append(source)

            if to_clean:
                for i in range(0, len(to_clean), MAX_VARS):
                    chunk = to_clean[i:i + MAX_VARS]
                    cur.execute('''
                        delete from source_info
                         where source in (%s)
                    ''' % ', '.join(['?'] * len(chunk)), chunk)

                con.commit()
        finally:
            con.close()

        for source in to_clean:
            reporter.report_prune_source_info(source)
Example #2
0
    def prune_source_infos(self):
        """Remove all source infos of files that no longer exist."""
        MAX_VARS = 999  # Default SQLITE_MAX_VARIABLE_NUMBER.
        con = self.connect_to_database()
        to_clean = []
        try:
            cur = con.cursor()
            cur.execute('''
                select distinct source from source_info
            ''')
            for source, in cur.fetchall():
                fs_path = os.path.join(self.env.root_path, source)
                if not os.path.exists(fs_path):
                    to_clean.append(source)

            if to_clean:
                for i in range(0, len(to_clean), MAX_VARS):
                    chunk = to_clean[i:i + MAX_VARS]
                    cur.execute('''
                        delete from source_info
                         where source in (%s)
                    ''' % ', '.join(['?'] * len(chunk)), chunk)

                con.commit()
        finally:
            con.close()

        for source in to_clean:
            reporter.report_prune_source_info(source)
Example #3
0
    def prune_source_infos(self):
        """Remove all source infos of files that no longer exist."""
        con = self.connect_to_database()
        to_clean = []
        try:
            cur = con.cursor()
            cur.execute('''
                select distinct source from source_info
            ''')
            for source, in cur.fetchall():
                fs_path = os.path.join(self.env.root_path, source)
                if not os.path.exists(fs_path):
                    to_clean.append(source)
            if to_clean:
                cur.execute(
                    '''
                    delete from source_info
                     where source in (%s)
                ''' % ', '.join(['?'] * len(to_clean)), to_clean)
                con.commit()
        finally:
            con.close()

        for source in to_clean:
            reporter.report_prune_source_info(source)
Example #4
0
    def prune_source_infos(self):
        """Remove all source infos of files that no longer exist."""
        con = self.connect_to_database()
        to_clean = []
        try:
            cur = con.cursor()
            cur.execute(
                """
                select distinct source from source_info
            """
            )
            for (source,) in cur.fetchall():
                fs_path = os.path.join(self.env.root_path, source)
                if not os.path.exists(fs_path):
                    to_clean.append(source)
            if to_clean:
                cur.execute(
                    """
                    delete from source_info
                     where source in (%s)
                """
                    % ", ".join(["?"] * len(to_clean)),
                    to_clean,
                )
                con.commit()
        finally:
            con.close()

        for source in to_clean:
            reporter.report_prune_source_info(source)