def _check_download_dir(link, download_dir, hashes):
 download_path = os.path.join(download_dir, link.filename)
 if os.path.exists(download_path):
  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 ) : download_path = os . path . join ( download_dir , link . filename ) if os . path . exists ( download_path ) : 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
check download_dir for previously downloaded file with correct hash if a correct file is found return its path else none .