From dbfbbab904bc549bc876e71f8c5e7b3b0e0ade6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Pluchino?= Date: Thu, 16 Feb 2012 23:41:26 +0100 Subject: [PATCH] Add changes requested --- src/Composer/Util/RemoteFilesystem.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Composer/Util/RemoteFilesystem.php b/src/Composer/Util/RemoteFilesystem.php index 036c0b2fa..2d4be57d6 100644 --- a/src/Composer/Util/RemoteFilesystem.php +++ b/src/Composer/Util/RemoteFilesystem.php @@ -58,7 +58,7 @@ class RemoteFilesystem * @param string $fileUrl The file URL * @param boolean $progess Display the progression * - * @return false|string The content + * @return string The content */ public function getContents($originUrl, $fileUrl, $progess = true) { @@ -75,7 +75,7 @@ class RemoteFilesystem * @param string $fileName the local filename * @param boolean $progess Display the progression * - * @throws \RuntimeException When the openssl extension is disabled + * @throws \RuntimeException When the file could not be downloaded */ protected function get($originUrl, $fileUrl, $fileName = null, $progess = true) { @@ -92,8 +92,7 @@ class RemoteFilesystem if ($this->io->hasAuthorization($originUrl)) { $auth = $this->io->getAuthorization($originUrl); $authStr = base64_encode($auth['username'] . ':' . $auth['password']); - $options['http']['header'] = "Authorization: Basic $authStr\r\n"; - + $options['http']['header'] = "Authorization: Basic $authStr\r\n"; } else if (null !== $this->io->getLastUsername()) { $authStr = base64_encode($this->io->getLastUsername() . ':' . $this->io->getLastPassword()); $options['http'] = array('header' => "Authorization: Basic $authStr\r\n"); @@ -107,15 +106,19 @@ class RemoteFilesystem } if (null !== $fileName) { - @copy($fileUrl, $fileName, $ctx); - + $result = @copy($fileUrl, $fileName, $ctx); } else { - $this->content = @file_get_contents($fileUrl, false, $ctx); + $result = @file_get_contents($fileUrl, false, $ctx); + $this->content = $result; } if ($this->progress) { $this->io->overwrite(" Downloading", false); } + + if (false === $result) { + throw new \RuntimeException("the '$fileUrl' file could not be downloaded"); + } } /**