diff --git a/src/Composer/Downloader/ArchiveDownloader.php b/src/Composer/Downloader/ArchiveDownloader.php index 570de63d8398..4f2467d71e3c 100644 --- a/src/Composer/Downloader/ArchiveDownloader.php +++ b/src/Composer/Downloader/ArchiveDownloader.php @@ -120,7 +120,9 @@ public function install(PackageInterface $package, $path, $output = true) } return $promise->then(function () use ($self, $package, $filesystem, $fileName, $temporaryDir, $path) { - $filesystem->unlink($fileName); + if (file_exists($fileName)) { + $filesystem->unlink($fileName); + } /** * Returns the folder content, excluding .DS_Store diff --git a/src/Composer/Downloader/ZipDownloader.php b/src/Composer/Downloader/ZipDownloader.php index a86d1da6b549..ca379072a668 100644 --- a/src/Composer/Downloader/ZipDownloader.php +++ b/src/Composer/Downloader/ZipDownloader.php @@ -184,7 +184,8 @@ public function extractWithZipArchive(PackageInterface $package, $file, $path) $zipArchive = $this->zipArchiveObject ?: new ZipArchive(); try { - if (true === ($retval = $zipArchive->open($file))) { + $retval = -1; + if (file_exists($file) && filesize($file) > 0 && true === ($retval = $zipArchive->open($file))) { $extractResult = $zipArchive->extractTo($path); if (true === $extractResult) { @@ -251,6 +252,8 @@ protected function getErrorMessage($retval, $file) return sprintf("Zip read error (%s)", $file); case ZipArchive::ER_SEEK: return sprintf("Zip seek error (%s)", $file); + case -1: + return sprintf("'%s' is a corrupted zip archive (0 bytes), try again.", $file); default: return sprintf("'%s' is not a valid zip archive, got error code: %s", $file, $retval); }