/** * Generate archive filename for a particular version of a package. * * @param PackageInterface $package The package to get a name for * * @return string A filename without an extension */ public function getPackageFilename($package) { $nameParts = array(preg_replace('#[^a-z0-9-_/]#i', '-', $package->getName())); if (preg_match('{^[a-f0-9]{40}$}', $package->getDistReference())) { $nameParts = array_merge($nameParts, array($package->getDistReference())); } else { $nameParts = array_merge($nameParts, array($package->getPrettyVersion(), $package->getDistReference())); } return implode('-', array_filter($nameParts, function ($p) { return !empty($p); })); }
/** * Get the cache file path (without cache-files-dir prefix). * * @param PackageInterface $p * @return type */ public function getCacheKey($p) { $distRef = $p->getDistReference(); if (preg_match('{^[a-f0-9]{40}$}', $distRef)) { return $p->getName() . '/' . $distRef . '.' . $p->getDistType(); } // Composer builds the key like this, but it doesn't work: //return $p->getName().'/'.$p->getVersion().'-'.$distRef.'.'.$p->getDistType(); // we need to apply the SHA1 fix from // https://github.com/krispypen/composer/commit/d8fa9ab57efdac94cd7135d96c2523932ac30f8b return $p->getName() . '/' . $p->getVersion() . '-' . $distRef . '-' . $p->getDistSha1Checksum() . '.' . $p->getDistType(); }