Browse Source

Use cache directory when downloading composer.phar

Since there is a cache dir there is no need to populate the project
directory with temp files. Plus the permissions on the project dir
might not allow that.
Dimitrios Kanellopoulos 12 years ago
parent
commit
9477e015bd
1 changed files with 5 additions and 1 deletions
  1. 5 1
      src/Composer/Command/SelfUpdateCommand.php

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

@@ -13,6 +13,7 @@
 namespace Composer\Command;
 namespace Composer\Command;
 
 
 use Composer\Composer;
 use Composer\Composer;
+use Composer\Factory;
 use Composer\Util\RemoteFilesystem;
 use Composer\Util\RemoteFilesystem;
 use Composer\Downloader\FilesystemException;
 use Composer\Downloader\FilesystemException;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Input\InputInterface;
@@ -42,8 +43,11 @@ EOT
 
 
     protected function execute(InputInterface $input, OutputInterface $output)
     protected function execute(InputInterface $input, OutputInterface $output)
     {
     {
+        $config = Factory::createConfig();
+        $cacheDir = $config->get('cache-dir');
+
         $localFilename = realpath($_SERVER['argv'][0]) ?: $_SERVER['argv'][0];
         $localFilename = realpath($_SERVER['argv'][0]) ?: $_SERVER['argv'][0];
-        $tempFilename = dirname($localFilename) . '/' . basename($localFilename, '.phar').'-temp.phar';
+        $tempFilename = $cacheDir . basename($localFilename, '.phar').'-temp.phar';
 
 
         // check for permissions in local filesystem before start connection process
         // check for permissions in local filesystem before start connection process
         if (!is_writable($tempDirectory = dirname($tempFilename))) {
         if (!is_writable($tempDirectory = dirname($tempFilename))) {