You are here

protected static function InPlaceUpdate::validateArchive in Automatic Updates 7

Validate the downloaded archive.

Parameters

string $directory: The location of the downloaded archive.

string $csig: The CSIG contents.

Throws

\SodiumException

1 call to InPlaceUpdate::validateArchive()
InPlaceUpdate::getArchive in ./InPlaceUpdate.php
Get an archive with the quasi-patch contents.

File

./InPlaceUpdate.php, line 245

Class

InPlaceUpdate
Class to apply in-place updates.

Code

protected static function validateArchive($directory, $csig) {
  $module_path = drupal_get_path('module', 'automatic_updates');
  $key = file_get_contents($module_path . '/artifacts/keys/root.pub');
  $verifier = new Verifier($key);
  $files = $verifier
    ->verifyCsigMessage($csig);
  $checksums = new ChecksumList($files, TRUE);
  $failed_checksums = new FailedCheckumFilter($checksums, $directory);
  if (iterator_count($failed_checksums)) {
    throw new \RuntimeException('The downloaded files did not match what was expected.');
  }
}