Fix ZipDownloader, fixes #221
parent
405f876fa6
commit
f5ac5b9b3e
|
@ -13,21 +13,27 @@
|
||||||
namespace Composer\Downloader;
|
namespace Composer\Downloader;
|
||||||
|
|
||||||
use Composer\Package\PackageInterface;
|
use Composer\Package\PackageInterface;
|
||||||
use Composer\Util\Process;
|
use Composer\Util\ProcessExecutor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||||
*/
|
*/
|
||||||
class ZipDownloader extends FileDownloader
|
class ZipDownloader extends FileDownloader
|
||||||
{
|
{
|
||||||
|
protected $process;
|
||||||
|
|
||||||
|
public function __construct(ProcessExecutor $process = null)
|
||||||
|
{
|
||||||
|
$this->process = $process ?: new ProcessExecutor;
|
||||||
|
}
|
||||||
|
|
||||||
protected function extract($file, $path)
|
protected function extract($file, $path)
|
||||||
{
|
{
|
||||||
if (!class_exists('ZipArchive')) {
|
if (!class_exists('ZipArchive')) {
|
||||||
// try to use unzip on *nix
|
// try to use unzip on *nix
|
||||||
if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
|
if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||||
$process = new Process('unzip '.escapeshellarg($file).' -d '.escapeshellarg($path));
|
$result = $this->process->execute('unzip '.escapeshellarg($file).' -d '.escapeshellarg($path));
|
||||||
$process->run();
|
if (0 == $result) {
|
||||||
if ($process->isSuccessful()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue