1
0
Fork 0

Allow downgrades to go through even though the target dir for archive extraction exists

pull/8948/head
Jordi Boggiano 2020-06-03 15:37:36 +02:00
parent 63041fbf50
commit 90bd351b8b
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 3 additions and 1 deletions

View File

@ -29,7 +29,9 @@ abstract class ArchiveDownloader extends FileDownloader
public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true) public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true)
{ {
$res = parent::download($package, $path, $prevPackage, $output); $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); throw new IrrecoverableDownloadException('Expected empty path to extract '.$package.' into but directory exists: '.$path);
} }