Skip to content

Commit

Permalink
Fix #202
Browse files Browse the repository at this point in the history
  • Loading branch information
theseer committed Jul 23, 2019
1 parent 30aabcd commit 84a7fff
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/shared/PharRegistry.php
Expand Up @@ -21,14 +21,11 @@ public function __construct(XmlFile $xmlFile, Directory $pharDirectory) {
}

public function addPhar(Phar $phar): Phar {
$destinationFile = $this->savePhar($phar->getFile());
$destinationFile = $this->savePhar($phar);
$pharNode = $this->dbFile->createElement('phar');
$pharNode->setAttribute('name', $phar->getName());
$pharNode->setAttribute('version', $phar->getVersion()->getVersionString());
$pharNode->setAttribute(
'location',
$this->pharDirectory . \DIRECTORY_SEPARATOR . $phar->getFile()->getFilename()
);
$pharNode->setAttribute('location', $destinationFile->asString());
$hashNode = $this->dbFile->createElement('hash', Sha1Hash::forContent($phar->getFile()->getContent())->asString());
$hashNode->setAttribute('type', 'sha1');
$pharNode->appendChild($hashNode);
Expand Down Expand Up @@ -173,16 +170,22 @@ public function getKnownSignatureFingerprints(string $alias): array {
return \array_unique($fingerprints);
}

private function savePhar(File $pharFile): Filename {
$destination = new Filename($this->getPharDestination($pharFile));
$pharFile->saveAs($destination);
private function savePhar(Phar $phar): Filename {
$destination = new Filename($this->getPharDestination($phar));
$phar->getFile()->saveAs($destination);
\chmod($destination->asString(), 0755);

return $destination;
}

private function getPharDestination(File $file): string {
return $this->pharDirectory . \DIRECTORY_SEPARATOR . $file->getFilename();
private function getPharDestination(Phar $phar): string {

return sprintf(
'%s/%s-%s.phar',
$this->pharDirectory,
$phar->getName(),
$phar->getVersion()->getVersionString()
);
}

private function getFirstMatchingPharNode(string $name, Version $version): ?DOMElement {
Expand Down

0 comments on commit 84a7fff

Please sign in to comment.