(config: ConfigParser, args: Namespace)
return await delete_unowned_files(
        mirror_base_path, executor, all_package_files, args.dry_run
    )
Crawl all saved JSON metadata or online to check we have all packages
    if delete - generate a diff of unowned files
Crawl all saved JSON metadata or online to check we have all packages
    if delete - generate a diff of unowned files
Crawl all saved JSON metadata or online to check we have all packages if delete - generate a diff of unowned files
async def metadata_verify(config: ConfigParser, args: Namespace) -> int:
    """Crawl all saved JSON metadata or online to check we have all packages
    if delete - generate a diff of unowned files"""
    all_package_files: List[Path] = []
    loop = asyncio.get_event_loop()

    storage_backend = next(
        iter(storage_backend_plugins(config=config, clear_cache=True))
    )

    mirror_base_path = storage_backend.PATH_BACKEND(config.get("mirror", "directory"))
    json_base = mirror_base_path / "web" / "json"
    workers = args.workers or config.getint("mirror", "workers")
    executor = concurrent.futures.ThreadPoolExecutor(max_workers=workers)

    logger.info(f"Starting verify for {mirror_base_path} with {workers} workers")
    try:
        json_files = await loop.run_in_executor(executor, os.listdir, json_base)
    except FileExistsError as fee:
        logger.error(f"Metadata base dir {json_base} does not exist: {fee}")
        return 2
    if not json_files:
        logger.error("No JSON metadata files found. Can not verify")
        return 3

    logger.debug(f"Found {len(json_files)} objects in {json_base}")
    logger.debug(f"Using a {workers} thread ThreadPoolExecutor")
    async with Master(
        config.get("mirror", "master"),
        config.getfloat("mirror", "timeout"),
        config.getfloat("mirror", "global-timeout", fallback=None),
    ) as master:
        await verify_producer(
            master,
            config,
            all_package_files,
            mirror_base_path,
            json_files,
            args,
            executor,
        )

    if not args.delete:
        return 0

    return await delete_unowned_files(
        mirror_base_path, executor, all_package_files, args.dry_run
    )
async def metadata_verify ( config : ConfigParser , args : Namespace ) -> int : all_package_files : List [ Path ] = [ ] loop = asyncio . get_event_loop ( ) storage_backend = next ( iter ( storage_backend_plugins ( config = config , clear_cache = True ) ) ) mirror_base_path = storage_backend . PATH_BACKEND ( config . get ( "mirror" , "directory" ) ) json_base = mirror_base_path / "web" / "json" workers = args . workers or config . getint ( "mirror" , "workers" ) executor = concurrent . futures . ThreadPoolExecutor ( max_workers = workers ) logger . info ( f"Starting verify for {mirror_base_path} with {workers} workers" ) try : json_files = await loop . run_in_executor ( executor , os . listdir , json_base ) except FileExistsError as fee : logger . error ( f"Metadata base dir {json_base} does not exist: {fee}" ) return 2 if not json_files : logger . error ( "No JSON metadata files found. Can not verify" ) return 3 logger . debug ( f"Found {len(json_files)} objects in {json_base}" ) logger . debug ( f"Using a {workers} thread ThreadPoolExecutor" ) async with Master ( config . get ( "mirror" , "master" ) , config . getfloat ( "mirror" , "timeout" ) , config . getfloat ( "mirror" , "global-timeout" , fallback = None ) , ) as master : await verify_producer ( master , config , all_package_files , mirror_base_path , json_files , args , executor , ) if not args . delete : return 0 return await delete_unowned_files ( mirror_base_path , executor , all_package_files , args . dry_run )