Merge remote-tracking branch 'romainneutron/zip-downloader'
commit
8bcb442d2b
|
@ -33,6 +33,19 @@ class ZipDownloader extends ArchiveDownloader
|
||||||
|
|
||||||
protected function extract($file, $path)
|
protected function extract($file, $path)
|
||||||
{
|
{
|
||||||
|
$processError = null;
|
||||||
|
|
||||||
|
// try to use unzip on *nix
|
||||||
|
if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||||
|
|
||||||
|
$command = 'unzip '.escapeshellarg($file).' -d '.escapeshellarg($path);
|
||||||
|
if (0 === $this->process->execute($command, $ignoredOutput)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
|
||||||
|
}
|
||||||
|
|
||||||
if (!class_exists('ZipArchive')) {
|
if (!class_exists('ZipArchive')) {
|
||||||
// php.ini path is added to the error message to help users find the correct file
|
// php.ini path is added to the error message to help users find the correct file
|
||||||
$iniPath = php_ini_loaded_file();
|
$iniPath = php_ini_loaded_file();
|
||||||
|
@ -43,19 +56,12 @@ class ZipDownloader extends ArchiveDownloader
|
||||||
$iniMessage = 'A php.ini file does not exist. You will have to create one.';
|
$iniMessage = 'A php.ini file does not exist. You will have to create one.';
|
||||||
}
|
}
|
||||||
|
|
||||||
$error = "You need the zip extension enabled to use the ZipDownloader.\n".
|
$error = "Could not decompress the archive, enable the PHP zip extension or install unzip.\n".
|
||||||
$iniMessage;
|
$iniMessage . "\n" . $processError;
|
||||||
|
|
||||||
// try to use unzip on *nix
|
|
||||||
if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
|
if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||||
$command = 'unzip '.escapeshellarg($file).' -d '.escapeshellarg($path);
|
$error = "You need the zip extension enabled to use the ZipDownloader.\n".
|
||||||
if (0 === $this->process->execute($command, $ignoredOutput)) {
|
$iniMessage;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$error = "Could not decompress the archive, enable the PHP zip extension or install unzip.\n".
|
|
||||||
$iniMessage . "\n" .
|
|
||||||
'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \RuntimeException($error);
|
throw new \RuntimeException($error);
|
||||||
|
|
Loading…
Reference in New Issue