(self, package: Package)
Before 4.0 we use to store backwards compatible named dirs for older pip
        This function checks for them and cleans them up
Before 4.0 we use to store backwards compatible named dirs for older pip
        This function checks for them and cleans them up
Before 4 . 0 we use to store backwards compatible named dirs for older pip This function checks for them and cleans them up
async def cleanup_non_pep_503_paths(self, package: Package) -> None:
        """
        Before 4.0 we use to store backwards compatible named dirs for older pip
        This function checks for them and cleans them up
        """

        def raw_simple_directory() -> Path:
            if self.hash_index:
                return self.webdir / "simple" / package.raw_name[0] / package.raw_name
            return self.webdir / "simple" / package.raw_name

        def normalized_legacy_simple_directory() -> Path:
            normalized_name_legacy = utils.bandersnatch_safe_name(package.raw_name)
            if self.hash_index:
                return (
                    self.webdir
                    / "simple"
                    / normalized_name_legacy[0]
                    / normalized_name_legacy
                )
            return self.webdir / "simple" / normalized_name_legacy

        if not self.cleanup:
            return

        logger.debug(f"Running Non PEP503 path cleanup for {package.raw_name}")
        for deprecated_dir in (
            raw_simple_directory(),
            normalized_legacy_simple_directory(),
        ):
            # Had to compare path strs as Windows did not match path objects ...
            if str(deprecated_dir) != str(self.simple_directory(package)):
                if not deprecated_dir.exists():
                    logger.debug(f"{deprecated_dir} does not exist. Not cleaning up")
                    continue

                logger.info(
                    f"Attempting to cleanup non PEP 503 simple dir: {deprecated_dir}"
                )
                try:
                    for file in deprecated_dir.glob("*"):
                        file.unlink(missing_ok=True)
                    deprecated_dir.rmdir()
                except Exception:
                    logger.exception(
                        f"Unable to cleanup non PEP 503 dir {deprecated_dir}"
                    )
async def cleanup_non_pep_503_paths ( self , package : Package ) -> None : def raw_simple_directory ( ) -> Path : if self . hash_index : return self . webdir / "simple" / package . raw_name [ 0 ] / package . raw_name return self . webdir / "simple" / package . raw_name def normalized_legacy_simple_directory ( ) -> Path : normalized_name_legacy = utils . bandersnatch_safe_name ( package . raw_name ) if self . hash_index : return ( self . webdir / "simple" / normalized_name_legacy [ 0 ] / normalized_name_legacy ) return self . webdir / "simple" / normalized_name_legacy if not self . cleanup : return logger . debug ( f"Running Non PEP503 path cleanup for {package.raw_name}" ) for deprecated_dir in ( raw_simple_directory ( ) , normalized_legacy_simple_directory ( ) , ) : # Had to compare path strs as Windows did not match path objects ... if str ( deprecated_dir ) != str ( self . simple_directory ( package ) ) : if not deprecated_dir . exists ( ) : logger . debug ( f"{deprecated_dir} does not exist. Not cleaning up" ) continue logger . info ( f"Attempting to cleanup non PEP 503 simple dir: {deprecated_dir}" ) try : for file in deprecated_dir . glob ( "*" ) : file . unlink ( missing_ok = True ) deprecated_dir . rmdir ( ) except Exception : logger . exception ( f"Unable to cleanup non PEP 503 dir {deprecated_dir}" )