1
0
Fork 0

Improve error reporting when unzip fails due to race condition in unhandled Promise, refs #8988

pull/8995/head
Jordi Boggiano 2020-06-17 10:42:37 +02:00
parent d1fedc3bd6
commit aaef3ff5ff
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 14 additions and 5 deletions

View File

@ -104,9 +104,15 @@ class ZipDownloader extends ArchiveDownloader
throw $processError; throw $processError;
} }
$io->writeError(' <warning>'.$processError->getMessage().'</warning>'); if (!is_file($file)) {
$io->writeError(' The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems)'); $io->writeError(' <warning>'.$processError->getMessage().'</warning>');
$io->writeError(' Unzip with unzip command failed, falling back to ZipArchive class'); $io->writeError(' <warning>This most likely is due to a custom installer plugin not handling the returned Promise from the downloader</warning>');
$io->writeError(' <warning>See https://github.com/composer/installers/commit/5006d0c28730ade233a8f42ec31ac68fb1c5c9bb for an example fix</warning>');
} else {
$io->writeError(' <warning>'.$processError->getMessage().'</warning>');
$io->writeError(' The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems)');
$io->writeError(' Unzip with unzip command failed, falling back to ZipArchive class');
}
return $self->extractWithZipArchive($package, $file, $path, true); return $self->extractWithZipArchive($package, $file, $path, true);
}; };
@ -114,9 +120,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) { return $promise->then(function ($process) use ($tryFallback, $command, $package, $file) {
if (!$process->isSuccessful()) { if (!$process->isSuccessful()) {
return $tryFallback(new \RuntimeException('Failed to extract '.$package->getName().': ('.$process->getExitCode().') '.$command."\n\n".$process->getErrorOutput())); $output = $process->getErrorOutput();
$output = str_replace(', '.$file.'.zip or '.$file.'.ZIP', '', $output);
return $tryFallback(new \RuntimeException('Failed to extract '.$package->getName().': ('.$process->getExitCode().') '.$command."\n\n".$output));
} }
}); });
} catch (\Exception $e) { } catch (\Exception $e) {