(link, download_dir, hashes)
return None
Check download_dir for previously downloaded file with correct hash
        If a correct file is found return its path else None
Check download_dir for previously downloaded file with correct hash
        If a correct file is found return its path else None
Check download_dir for previously downloaded file with correct hash If a correct file is found return its path else None
def _check_download_dir(link, download_dir, hashes):
    # type: (Link, str, Optional[Hashes]) -> Optional[str]
    """ Check download_dir for previously downloaded file with correct hash
        If a correct file is found return its path else None
    """
    download_path = os.path.join(download_dir, link.filename)
    if os.path.exists(download_path):
        # If already downloaded, does its hash match?
        logger.info('File was already downloaded %s', download_path)
        if hashes:
            try:
                hashes.check_against_path(download_path)
            except HashMismatch:
                logger.warning(
                    'Previously-downloaded file %s has bad hash. '
                    'Re-downloading.',
                    download_path
                )
                os.unlink(download_path)
                return None
        return download_path
    return None
def _check_download_dir ( link , download_dir , hashes ) : # type: (Link, str, Optional[Hashes]) -> Optional[str] download_path = os . path . join ( download_dir , link . filename ) if os . path . exists ( download_path ) : # If already downloaded, does its hash match? logger . info ( 'File was already downloaded %s' , download_path ) if hashes : try : hashes . check_against_path ( download_path ) except HashMismatch : logger . warning ( 'Previously-downloaded file %s has bad hash. ' 'Re-downloading.' , download_path ) os . unlink ( download_path ) return None return download_path return None