1
0
Fork 0

Avoid emptying the directory before extracting an archive into it, check that it is empty instead

pull/8729/head
Jordi Boggiano 2020-03-28 20:36:37 +01:00
parent 6679dde713
commit 73251691a0
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 4 additions and 1 deletions

View File

@ -38,7 +38,10 @@ abstract class ArchiveDownloader extends FileDownloader
$this->io->writeError('Extracting archive', false);
}
$this->filesystem->emptyDirectory($path);
$this->filesystem->ensureDirectoryExists($path);
if (!$this->filesystem->isDirEmpty($path)) {
throw new \RuntimeException('Expected empty path to extract '.$package.' into but directory exists: '.$path);
}
$temporaryDir = $this->config->get('vendor-dir').'/composer/'.substr(md5(uniqid('', true)), 0, 8);
$fileName = $this->getFileName($package, $path);