1
0
Fork 0

Fix output of FileDownloader and related to avoid async issues

pull/9730/head
Jordi Boggiano 2021-02-25 12:03:09 +01:00
parent 9809350753
commit b3951b8804
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
3 changed files with 38 additions and 8 deletions

View File

@ -34,9 +34,7 @@ abstract class ArchiveDownloader extends FileDownloader
public function install(PackageInterface $package, $path, $output = true) public function install(PackageInterface $package, $path, $output = true)
{ {
if ($output) { if ($output) {
$this->io->writeError(" - " . InstallOperation::format($package).": Extracting archive"); $this->io->writeError(" - " . InstallOperation::format($package) . $this->getInstallOperationAppendix($package, $path));
} else {
$this->io->writeError('Extracting archive', false);
} }
$vendorDir = $this->config->get('vendor-dir'); $vendorDir = $this->config->get('vendor-dir');
@ -151,6 +149,14 @@ abstract class ArchiveDownloader extends FileDownloader
}); });
} }
/**
* {@inheritDoc}
*/
protected function getInstallOperationAppendix(PackageInterface $package, $path)
{
return ': Extracting archive';
}
/** /**
* Extract file to directory * Extract file to directory
* *

View File

@ -355,10 +355,10 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
*/ */
public function update(PackageInterface $initial, PackageInterface $target, $path) public function update(PackageInterface $initial, PackageInterface $target, $path)
{ {
$this->io->writeError(" - " . UpdateOperation::format($initial, $target) . ": ", false); $this->io->writeError(" - " . UpdateOperation::format($initial, $target) . $this->getInstallOperationAppendix($target, $path));
$promise = $this->remove($initial, $path, false); $promise = $this->remove($initial, $path, false);
if ($promise === null || !$promise instanceof PromiseInterface) { if (!$promise instanceof PromiseInterface) {
$promise = \React\Promise\resolve(); $promise = \React\Promise\resolve();
} }
$self = $this; $self = $this;
@ -401,6 +401,18 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
return rtrim($this->config->get('vendor-dir').'/composer/tmp-'.md5($package.spl_object_hash($package)).'.'.pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_EXTENSION), '.'); return rtrim($this->config->get('vendor-dir').'/composer/tmp-'.md5($package.spl_object_hash($package)).'.'.pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_EXTENSION), '.');
} }
/**
* Gets appendix message to add to the "- Upgrading x" string being output on update
*
* @param PackageInterface $package package instance
* @param string $path download path
* @return string
*/
protected function getInstallOperationAppendix(PackageInterface $package, $path)
{
return '';
}
/** /**
* Process the download url * Process the download url
* *

View File

@ -80,9 +80,7 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
if (realpath($path) === $realUrl) { if (realpath($path) === $realUrl) {
if ($output) { if ($output) {
$this->io->writeError(" - " . InstallOperation::format($package).': Source already present'); $this->io->writeError(" - " . InstallOperation::format($package) . $this->getInstallOperationAppendix($package, $path));
} else {
$this->io->writeError('Source already present', false);
} }
return; return;
@ -216,6 +214,20 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
} }
} }
/**
* {@inheritDoc}
*/
protected function getInstallOperationAppendix(PackageInterface $package, $path)
{
$realUrl = realpath($package->getDistUrl());
if (realpath($path) === $realUrl) {
return ': Source already present';
}
return '';
}
/** /**
* Returns true if junctions can be created and safely used on Windows * Returns true if junctions can be created and safely used on Windows
* *