Make sure that if cleanup happens before install completes on zip updates, we do not report bogus errors, fixes #9804
parent
1ef7076703
commit
915f3f4fb6
|
@ -26,6 +26,26 @@ use Composer\DependencyResolver\Operation\InstallOperation;
|
|||
*/
|
||||
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}
|
||||
* @throws \RuntimeException
|
||||
|
|
|
@ -149,8 +149,12 @@ class ZipDownloader extends ArchiveDownloader
|
|||
try {
|
||||
$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 (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 = str_replace(', '.$file.'.zip or '.$file.'.ZIP', '', $output);
|
||||
|
||||
|
|
Loading…
Reference in New Issue