|
|
|
@ -27,7 +27,9 @@ use Composer\EventDispatcher\EventDispatcher;
|
|
|
|
|
use Composer\Util\Filesystem;
|
|
|
|
|
use Composer\Util\HttpDownloader;
|
|
|
|
|
use Composer\Util\Url as UrlUtil;
|
|
|
|
|
use Composer\Util\ProcessExecutor;
|
|
|
|
|
use Composer\Downloader\TransportException;
|
|
|
|
|
use React\Promise\PromiseInterface;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Base downloader for files
|
|
|
|
@ -51,6 +53,8 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
|
|
|
|
protected $cache;
|
|
|
|
|
/** @var EventDispatcher */
|
|
|
|
|
protected $eventDispatcher;
|
|
|
|
|
/** @var ProcessExecutor */
|
|
|
|
|
protected $process;
|
|
|
|
|
/**
|
|
|
|
|
* @private this is only public for php 5.3 support in closures
|
|
|
|
|
*/
|
|
|
|
@ -67,14 +71,15 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
|
|
|
|
* @param Cache $cache Cache instance
|
|
|
|
|
* @param Filesystem $filesystem The filesystem
|
|
|
|
|
*/
|
|
|
|
|
public function __construct(IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null, Cache $cache = null, Filesystem $filesystem = null)
|
|
|
|
|
public function __construct(IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null, Cache $cache = null, Filesystem $filesystem = null, ProcessExecutor $process = null)
|
|
|
|
|
{
|
|
|
|
|
$this->io = $io;
|
|
|
|
|
$this->config = $config;
|
|
|
|
|
$this->eventDispatcher = $eventDispatcher;
|
|
|
|
|
$this->httpDownloader = $httpDownloader;
|
|
|
|
|
$this->filesystem = $filesystem ?: new Filesystem();
|
|
|
|
|
$this->cache = $cache;
|
|
|
|
|
$this->process = $process ?: new ProcessExecutor($io);
|
|
|
|
|
$this->filesystem = $filesystem ?: new Filesystem($this->process);
|
|
|
|
|
|
|
|
|
|
if ($this->cache && $this->cache->gcIsNecessary()) {
|
|
|
|
|
$this->cache->gc($config->get('cache-files-ttl'), $config->get('cache-files-maxsize'));
|
|
|
|
@ -333,10 +338,19 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
|
|
|
|
$actionName = VersionParser::isUpgrade($initial->getVersion(), $target->getVersion()) ? 'Upgrading' : 'Downgrading';
|
|
|
|
|
$this->io->writeError(" - " . $actionName . " <info>" . $name . "</info> (<comment>" . $from . "</comment> => <comment>" . $to . "</comment>): ", false);
|
|
|
|
|
|
|
|
|
|
$this->remove($initial, $path, false);
|
|
|
|
|
$this->install($target, $path, false);
|
|
|
|
|
$promise = $this->remove($initial, $path, false);
|
|
|
|
|
if (!$promise instanceof PromiseInterface) {
|
|
|
|
|
$promise = \React\Promise\resolve();
|
|
|
|
|
}
|
|
|
|
|
$self = $this;
|
|
|
|
|
$io = $this->io;
|
|
|
|
|
|
|
|
|
|
return $promise->then(function () use ($self, $target, $path, $io) {
|
|
|
|
|
$promise = $self->install($target, $path, false);
|
|
|
|
|
$io->writeError('');
|
|
|
|
|
|
|
|
|
|
$this->io->writeError('');
|
|
|
|
|
return $promise;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -410,9 +424,10 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
|
|
|
|
$output = '';
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$res = $this->download($package, $targetDir.'_compare', null, false);
|
|
|
|
|
$this->download($package, $targetDir.'_compare', null, false);
|
|
|
|
|
$this->httpDownloader->wait();
|
|
|
|
|
$res = $this->install($package, $targetDir.'_compare', false);
|
|
|
|
|
$this->install($package, $targetDir.'_compare', false);
|
|
|
|
|
$this->process->wait();
|
|
|
|
|
|
|
|
|
|
$comparer = new Comparer();
|
|
|
|
|
$comparer->setSource($targetDir.'_compare');
|
|
|
|
|