diff --git a/src/Composer/Command/SelfUpdateCommand.php b/src/Composer/Command/SelfUpdateCommand.php index 3192f47d3..b9381abb1 100644 --- a/src/Composer/Command/SelfUpdateCommand.php +++ b/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('The download of the new composer version failed for an unexpected reason'); + + return 1; + } + try { chmod($tempFilename, 0777 & ~umask()); // test the phar validity