Browse Source

Fix self-update error handling, fixes #1738

Jordi Boggiano 12 years ago
parent
commit
ad69d15590
1 changed files with 7 additions and 1 deletions
  1. 7 1
      src/Composer/Command/SelfUpdateCommand.php

+ 7 - 1
src/Composer/Command/SelfUpdateCommand.php

@@ -50,10 +50,16 @@ EOT
 
             $remoteFilename = $protocol . '://getcomposer.org/composer.phar';
             $localFilename = $_SERVER['argv'][0];
-            $tempFilename = basename($localFilename, '.phar').'-temp.phar';
+            $tempFilename = dirname($localFilename) . '/' . basename($localFilename, '.phar').'-temp.phar';
 
             $rfs->copy('getcomposer.org', $remoteFilename, $tempFilename);
 
+            if (!file_exists($tempFilename)) {
+                $output->writeln('<error>The download of the new composer version failed for an unexpected reason');
+
+                return 1;
+            }
+
             try {
                 chmod($tempFilename, 0777 & ~umask());
                 // test the phar validity