From 28c7d0ea5d4477d3f74236c72d9548fa9760c2f1 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 2 Jun 2021 13:46:51 +0200 Subject: [PATCH] Avoid creating new processes to remove directories which we know are empty, which speeds things up a lot on windows --- src/Composer/Downloader/ArchiveDownloader.php | 2 +- src/Composer/Downloader/FileDownloader.php | 2 +- src/Composer/Util/Filesystem.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Composer/Downloader/ArchiveDownloader.php b/src/Composer/Downloader/ArchiveDownloader.php index cc667e692..27b86cf9d 100644 --- a/src/Composer/Downloader/ArchiveDownloader.php +++ b/src/Composer/Downloader/ArchiveDownloader.php @@ -137,7 +137,7 @@ abstract class ArchiveDownloader extends FileDownloader }; $renameAsOne = false; - if (!file_exists($path) || ($filesystem->isDirEmpty($path) && $filesystem->removeDirectory($path))) { + if (!file_exists($path) || ($filesystem->isDirEmpty($path) && $filesystem->removeDirectoryPhp($path))) { $renameAsOne = true; } diff --git a/src/Composer/Downloader/FileDownloader.php b/src/Composer/Downloader/FileDownloader.php index 63cba2e3c..0062d22b8 100644 --- a/src/Composer/Downloader/FileDownloader.php +++ b/src/Composer/Downloader/FileDownloader.php @@ -306,7 +306,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface foreach ($dirsToCleanUp as $dir) { if (is_dir($dir) && $this->filesystem->isDirEmpty($dir) && realpath($dir) !== getcwd()) { - $this->filesystem->removeDirectory($dir); + $this->filesystem->removeDirectoryPhp($dir); } } diff --git a/src/Composer/Util/Filesystem.php b/src/Composer/Util/Filesystem.php index c83df2797..8335052c7 100644 --- a/src/Composer/Util/Filesystem.php +++ b/src/Composer/Util/Filesystem.php @@ -188,7 +188,7 @@ class Filesystem throw new \RuntimeException('Aborting an attempted deletion of '.$directory.', this was probably not intended, if it is a real use case please report it.'); } - if (1||!\function_exists('proc_open')) { + if (!\function_exists('proc_open')) { return $this->removeDirectoryPhp($directory); }