def rebuild(self, paths=None):
        """
        Scans the paths for files and rebuilds the database.
        """
        if paths:
            logger.info('Just adding new paths')
        else:
            logger.info('Rebuilding database')
            self.truncate()
            paths = self.paths
        
        unsplitable_paths = set()
        if self.unsplitable_mode or self.exact_mode:
            logger.info('Special modes enabled, doing a preliminary scan')
            for root_path in paths:
                logger.info(root_path % 'Preliminary scanning %s')
                for root, dirs, files in os.walk(root_path):
                    if is_unsplitable(files):
                        sep_root = root.split(os.sep)
                        name = get_root_of_unsplitable(root.split(os.sep))
                        while sep_root[-1] != name:
                            sep_root.pop()
                        path = os.path.join(*sep_root)
                        logger.debug('Found unsplitable path %r' % path)
                        unsplitable_paths.add(path)
                logger.info('Done preliminary scanning %s' % root_path)
        
        for root_path in paths:
            logger.info('Scanning %s' % root_path)
            for root, dirs, files in os.walk(root_path):
                unsplitable = False
                if self.unsplitable_mode or self.exact_mode:
                    sep_root = root.split(os.sep)
                    while sep_root:
                        if os.path.join(*sep_root) in unsplitable_paths:
                            break
                        sep_root.pop()
                    
                    if sep_root:
                        unsplitable = True
                        if self.unsplitable_mode:
                            unsplitable_name = sep_root[-1]
                            logger.info('Looks like we found a unsplitable release in %r' % (os.sep.join(sep_root)))
                            for f in files:
                                self.insert_into_database(root, f, 'unsplitable', unsplitable_name=unsplitable_name)
                            continue
                
                if not unsplitable:
                    if self.normal_mode:
                        for f in files:
                            if self.skip_file(f):
                                continue
                            
                            self.insert_into_database(root, f, 'normal')
                        
                    if self.exact_mode:
                        for f in files:
                            self.insert_into_database(root, f, 'exact', 'f')
                        
                        for d in dirs:
                            self.insert_into_database(root, d, 'exact', 'd')
                
                if self.hash_name_mode or self.hash_size_mode or self.hash_slow_mode:
                    for f in files:
                        if self.hash_size_mode or self.hash_slow_mode:
                            self.insert_into_database(root, f, 'hash_store_size')
                        
                        if self.hash_name_mode:
                            self.insert_into_database(root, f, 'hash_store_name')

                    
            logger.info('Done scanning %s' % root_path)
        self.db.sync()
dataset/ETHPy150Open JohnDoee/autotorrent/autotorrent/db.py/Database.rebuild/swapped operands of `%`