mirror of
https://github.com/composer/composer
synced 2025-05-11 01:22:54 +00:00
Merge pull request #561 from stloyd/patch-3
[ZipDownloader] If `unzip` command failed, give cleaner error.
This commit is contained in:
commit
2efe6d6d4c
1 changed files with 7 additions and 3 deletions
|
@ -33,15 +33,19 @@ class ZipDownloader extends ArchiveDownloader
|
||||||
protected function extract($file, $path)
|
protected function extract($file, $path)
|
||||||
{
|
{
|
||||||
if (!class_exists('ZipArchive')) {
|
if (!class_exists('ZipArchive')) {
|
||||||
|
$error = 'You need the zip extension enabled to use the ZipDownloader';
|
||||||
|
|
||||||
// try to use unzip on *nix
|
// try to use unzip on *nix
|
||||||
if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
|
if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||||
$result = $this->process->execute('unzip '.escapeshellarg($file).' -d '.escapeshellarg($path), $ignoredOutput);
|
$command = 'unzip '.escapeshellarg($file).' -d '.escapeshellarg($path);
|
||||||
if (0 == $result) {
|
if (0 === $this->process->execute($command, $ignoredOutput)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$error = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \RuntimeException('You need the zip extension enabled to use the ZipDownloader');
|
throw new \RuntimeException($error);
|
||||||
}
|
}
|
||||||
|
|
||||||
$zipArchive = new ZipArchive();
|
$zipArchive = new ZipArchive();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue