function _make_verify_checksums

8.0.x make.download.inc _make_verify_checksums($info, $filename)
6.x make.download.inc _make_verify_checksums($info, $filename)
7.x make.download.inc _make_verify_checksums($info, $filename)
5.x make.download.inc _make_verify_checksums($info, $filename)
master make.download.inc _make_verify_checksums($info, $filename)

Test that any supplied hash values match the hash of the file content.

Unsupported hash algorithms are reported as failure.

2 calls to _make_verify_checksums()
DrushMakeProject::applyPatches in commands/make/make.project.inc
Retrieve and apply any patches specified by the makefile to this project.
make_download_file in commands/make/make.download.inc
Downloads a file to the specified location.

File

commands/make/make.download.inc, line 511
Download-specific functions for Drush Make.

Code

function _make_verify_checksums($info, $filename) {
  $hash_algos = array('md5', 'sha1', 'sha256', 'sha512');
  // We only have something to do if a key is an
  // available function.
  if (array_intersect(array_keys($info), $hash_algos)) {
    $content = file_get_contents($filename);
    foreach ($hash_algos as $algo) {
      if (!empty($info[$algo])) {
        $hash = _make_hash($algo, $content);
        if ($hash !== $info[$algo]) {
          $args = array(
            '@algo' => $algo,
            '@file' => basename($filename),
            '@expected' => $info[$algo],
            '@hash' => $hash,
          );
          make_error('DOWNLOAD_ERROR', dt('Checksum @algo verification failed for @file. Expected @expected, received @hash.', $args));
          return FALSE;
        }
      }
    }
  }
  return TRUE;
}