1
0
Fork 0

Make sure that if cleanup happens before install completes on zip updates, we do not report bogus errors, fixes #9804

pull/10164/head
Jordi Boggiano 2021-10-15 10:42:44 +02:00
parent 1ef7076703
commit 915f3f4fb6
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
2 changed files with 25 additions and 1 deletions

View File

@ -26,6 +26,26 @@ use Composer\DependencyResolver\Operation\InstallOperation;
*/ */
abstract class ArchiveDownloader extends FileDownloader abstract class ArchiveDownloader extends FileDownloader
{ {
/**
* @var array<string, true>
* @protected
*/
public $cleanupExecuted = array();
public function prepare($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
{
unset($this->cleanupExecuted[$package->getName()]);
return parent::prepare($type, $package, $path, $prevPackage);
}
public function cleanup($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
{
$this->cleanupExecuted[$package->getName()] = true;
return parent::cleanup($type, $package, $path, $prevPackage);
}
/** /**
* {@inheritDoc} * {@inheritDoc}
* @throws \RuntimeException * @throws \RuntimeException

View File

@ -149,8 +149,12 @@ class ZipDownloader extends ArchiveDownloader
try { try {
$promise = $this->process->executeAsync($command); $promise = $this->process->executeAsync($command);
return $promise->then(function ($process) use ($tryFallback, $command, $package, $file) { return $promise->then(function ($process) use ($tryFallback, $command, $package, $file, $self) {
if (!$process->isSuccessful()) { if (!$process->isSuccessful()) {
if (isset($self->cleanupExecuted[$package->getName()])) {
throw new \RuntimeException('Failed to extract '.$package->getName().' as the installation was aborted by another package operation.');
}
$output = $process->getErrorOutput(); $output = $process->getErrorOutput();
$output = str_replace(', '.$file.'.zip or '.$file.'.ZIP', '', $output); $output = str_replace(', '.$file.'.zip or '.$file.'.ZIP', '', $output);