Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _verify_checksum(log, metadata_path, dry_run=True):
dataset_path, all_files = path_utils.get_dataset_paths(metadata_path)
checksum_file = _expected_checksum_path(dataset_path)
if not checksum_file.exists():
# Ingested data doesn't currently have them, so it's only a warning.
log.warning("checksum.missing", checksum_file=checksum_file)
return None
ch = verify.PackageChecksum()
ch.read(checksum_file)
if not dry_run:
for file, successful in ch.iteratively_verify():
if successful:
log.debug("checksum.pass", file=file)
else:
log.error("checksum.failure", file=file)
return False
log.debug("copy.verify", file_count=len(all_files))
return True