1
0
Fork 0

Remove forced dir removal before install, fixes #3035

pull/2995/merge
Jordi Boggiano 2014-06-04 14:20:36 +02:00
parent f16e3a88e2
commit 71397f82e4
3 changed files with 21 additions and 4 deletions

View File

@ -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);

View File

@ -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)) {

View File

@ -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);
}
}
}
}
/**