1
0
Fork 0

Restore old behavior of wiping dir contents before installing, fixes #8988

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

View File

@ -29,11 +29,6 @@ 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)
{ {
// 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); return parent::download($package, $path, $prevPackage, $output);
} }
@ -50,10 +45,7 @@ abstract class ArchiveDownloader extends FileDownloader
$this->io->writeError('Extracting archive', false); $this->io->writeError('Extracting archive', false);
} }
$this->filesystem->ensureDirectoryExists($path); $this->filesystem->emptyDirectory($path);
if (!$this->filesystem->isDirEmpty($path)) {
throw new \UnexpectedValueException('Expected empty path to extract '.$package.' into but directory exists: '.$path);
}
do { do {
$temporaryDir = $this->config->get('vendor-dir').'/composer/'.substr(md5(uniqid('', true)), 0, 8); $temporaryDir = $this->config->get('vendor-dir').'/composer/'.substr(md5(uniqid('', true)), 0, 8);