1
0
Fork 0

Merge pull request #4851 from curry684/pull-4431

Fixes in path repository handling of removed or nested sources
pull/4690/merge
Jordi Boggiano 2016-02-14 19:16:16 +00:00
commit 8db550b118
1 changed files with 15 additions and 9 deletions

View File

@ -29,6 +29,21 @@ class PathDownloader extends FileDownloader
*/ */
public function download(PackageInterface $package, $path) public function download(PackageInterface $package, $path)
{ {
$url = $package->getDistUrl();
$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 (strpos(realpath($path) . DIRECTORY_SEPARATOR, $realUrl . DIRECTORY_SEPARATOR) === 0) {
throw new \RuntimeException(sprintf(
'Package %s cannot install to "%s" inside its source at "%s"',
$package->getName(), realpath($path), $realUrl
));
}
$fileSystem = new Filesystem(); $fileSystem = new Filesystem();
$this->filesystem->removeDirectory($path); $this->filesystem->removeDirectory($path);
@ -38,15 +53,6 @@ class PathDownloader extends FileDownloader
$package->getFullPrettyVersion() $package->getFullPrettyVersion()
)); ));
$url = $package->getDistUrl();
$realUrl = realpath($url);
if (false === $realUrl || !file_exists($realUrl) || !is_dir($realUrl)) {
throw new \RuntimeException(sprintf(
'Path "%s" is not found',
$url
));
}
try { try {
$shortestPath = $this->filesystem->findShortestPath($path, $realUrl); $shortestPath = $this->filesystem->findShortestPath($path, $realUrl);
$fileSystem->symlink($shortestPath, $path); $fileSystem->symlink($shortestPath, $path);