From 90bd351b8be5e98fa840461384c65154332a960e Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 3 Jun 2020 15:37:36 +0200 Subject: [PATCH] Allow downgrades to go through even though the target dir for archive extraction exists --- src/Composer/Downloader/ArchiveDownloader.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Composer/Downloader/ArchiveDownloader.php b/src/Composer/Downloader/ArchiveDownloader.php index 666c33e01..283d0103e 100644 --- a/src/Composer/Downloader/ArchiveDownloader.php +++ b/src/Composer/Downloader/ArchiveDownloader.php @@ -29,7 +29,9 @@ abstract class ArchiveDownloader extends FileDownloader public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true) { $res = parent::download($package, $path, $prevPackage, $output); - if (is_dir($path) && !$this->filesystem->isDirEmpty($path)) { + + // if not downgrading and the dir already exists it seems we have an inconsistent state in the vendor dir and the user should fix it + if (!$prevPackage && is_dir($path) && !$this->filesystem->isDirEmpty($path)) { throw new IrrecoverableDownloadException('Expected empty path to extract '.$package.' into but directory exists: '.$path); }