function PathDownloader::download
@inheritDoc
Overrides FileDownloader::download
File
-
vendor/
composer/ composer/ src/ Composer/ Downloader/ PathDownloader.php, line 42
Class
- PathDownloader
- Download a package from a local path.
Namespace
Composer\DownloaderCode
public function download(PackageInterface $package, string $path, ?PackageInterface $prevPackage = null, bool $output = true) : PromiseInterface {
$path = Filesystem::trimTrailingSlash($path);
$url = $package->getDistUrl();
if (null === $url) {
throw new \RuntimeException('The package ' . $package->getPrettyName() . ' has no dist url configured, cannot download.');
}
$realUrl = realpath($url);
if (false === $realUrl || !file_exists($realUrl) || !is_dir($realUrl)) {
throw new \RuntimeException(sprintf('Source path "%s" is not found for package %s', $url, $package->getName()));
}
if (realpath($path) === $realUrl) {
return \React\Promise\resolve(null);
}
if (strpos(realpath($path) . DIRECTORY_SEPARATOR, $realUrl . DIRECTORY_SEPARATOR) === 0) {
// IMPORTANT NOTICE: If you wish to change this, don't. You are wasting your time and ours.
//
// Please see https://github.com/composer/composer/pull/5974 and https://github.com/composer/composer/pull/6174
// for previous attempts that were shut down because they did not work well enough or introduced too many risks.
throw new \RuntimeException(sprintf('Package %s cannot install to "%s" inside its source at "%s"', $package->getName(), realpath($path), $realUrl));
}
return \React\Promise\resolve(null);
}