Remove forced dir removal before install, fixes #3035

main
Jordi Boggiano 10 years ago
parent f16e3a88e2
commit 71397f82e4

@ -107,8 +107,7 @@ class FileDownloader implements DownloaderInterface
protected function doDownload(PackageInterface $package, $path, $url)
{
$this->filesystem->removeDirectory($path);
$this->filesystem->ensureDirectoryExists($path);
$this->filesystem->emptyDirectory($path);
$fileName = $this->getFileName($package, $path);

@ -55,7 +55,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
}
$this->io->write(" - Installing <info>" . $package->getName() . "</info> (<comment>" . VersionParser::formatVersion($package) . "</comment>)");
$this->filesystem->removeDirectory($path);
$this->filesystem->emptyDirectory($path);
$urls = $package->getSourceUrls();
while ($url = array_shift($urls)) {

@ -74,7 +74,25 @@ class Filesystem
{
$dir = rtrim($dir, '/\\');
return count($this->realpathGlob($dir.'/*') ?: array()) === 0 && count($this->realpathGlob($dir.'/.*') ?: array()) === 2;
return count($this->realpathGlob($dir.'/*')) === 0 && count($this->realpathGlob($dir.'/.*')) === 2;
}
public function emptyDirectory($dir, $ensureDirectoryExists = true)
{
if ($ensureDirectoryExists) {
$this->ensureDirectoryExists($dir);
}
if (is_dir($dir)) {
foreach ($this->realpathGlob(rtrim($dir, '\\/').'/*') as $path) {
$this->remove($path);
}
foreach ($this->realpathGlob(rtrim($dir, '\\/').'/.*') as $path) {
if (basename($path) !== '..' && basename($path) !== '.') {
$this->remove($path);
}
}
}
}
/**

Loading…
Cancel
Save