Exemplo n.º 1
0
 /**
  * @expectedException \LogicException
  * @covers Aws\Common\Hash\TreeHash::addChecksum
  */
 public function testCannotAddChecksumsAfterHashCalculation()
 {
     $chunkHash = new TreeHash('sha256');
     $chunkHash->addData('foo');
     $chunkHash->getHash();
     $chunkHash->addChecksum('bar');
 }
 /**
  * @return string
  */
 public function getRootChecksum()
 {
     if (!$this->rootChecksum) {
         $this->rootChecksum = TreeHash::fromChecksums(array_map(function (UploadPart $part) {
             return $part->getChecksum();
         }, $this->uploadParts))->getHash();
     }
     return $this->rootChecksum;
 }
Exemplo n.º 3
0
function downloadJob(Job $job)
{
    $filename = "E:/glacier/storage/" . $job->get('start') . "-" . $job->get('end');
    $oResult = client()->getJobOutput(array('accountId' => '-', 'vaultName' => VAULT, 'jobId' => $job->get('jobId'), 'saveAs' => $filename));
    $contents = file_get_contents($filename);
    $checksum = $oResult->get('checksum');
    $equal = \Aws\Common\Hash\TreeHash::validateChecksum($contents1, $checksum);
    if (!$equal) {
        echo "Restarting job due to incorrect checksum: {$resulting_checksum} is not equal to {$checksum}";
        $job->set('finished', 0);
        $job->set('running', 0);
    } else {
        echo "downloaded job: " . $job->get('jobId') . PHP_EOL;
        $job->set('hash', $oResult->get('checksum'));
        $job->set('finished', 1);
        $job->set('running', 0);
    }
}