From d1fedc3bd62cea10bc847a980fdb874af19b2b8d Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 17 Jun 2020 10:42:05 +0200 Subject: [PATCH] Restore old behavior of wiping dir contents before installing, fixes #8988 --- src/Composer/Downloader/ArchiveDownloader.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/Composer/Downloader/ArchiveDownloader.php b/src/Composer/Downloader/ArchiveDownloader.php index 14b434b74..a78aa95bc 100644 --- a/src/Composer/Downloader/ArchiveDownloader.php +++ b/src/Composer/Downloader/ArchiveDownloader.php @@ -29,11 +29,6 @@ abstract class ArchiveDownloader extends FileDownloader { public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true) { - // if not upgrading/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); - } - return parent::download($package, $path, $prevPackage, $output); } @@ -50,10 +45,7 @@ abstract class ArchiveDownloader extends FileDownloader $this->io->writeError('Extracting archive', false); } - $this->filesystem->ensureDirectoryExists($path); - if (!$this->filesystem->isDirEmpty($path)) { - throw new \UnexpectedValueException('Expected empty path to extract '.$package.' into but directory exists: '.$path); - } + $this->filesystem->emptyDirectory($path); do { $temporaryDir = $this->config->get('vendor-dir').'/composer/'.substr(md5(uniqid('', true)), 0, 8);