From 67261e8d4707eacf759782429c97f257d0f0d940 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 25 Feb 2021 11:19:33 +0100 Subject: [PATCH] Make package removals async as well, refs #9618 --- src/Composer/Downloader/FileDownloader.php | 10 +++++++--- src/Composer/Downloader/VcsDownloader.php | 11 ++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/Composer/Downloader/FileDownloader.php b/src/Composer/Downloader/FileDownloader.php index a99ea79a0..b6d888665 100644 --- a/src/Composer/Downloader/FileDownloader.php +++ b/src/Composer/Downloader/FileDownloader.php @@ -380,9 +380,13 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface if ($output) { $this->io->writeError(" - " . UninstallOperation::format($package)); } - if (!$this->filesystem->removeDirectory($path)) { - throw new \RuntimeException('Could not completely delete '.$path.', aborting.'); - } + $promise = $this->filesystem->removeDirectoryAsync($path); + + return $promise->then(function($result) use ($path) { + if (!$result) { + throw new \RuntimeException('Could not completely delete '.$path.', aborting.'); + } + }); } /** diff --git a/src/Composer/Downloader/VcsDownloader.php b/src/Composer/Downloader/VcsDownloader.php index 4b5f94f0c..15095854e 100644 --- a/src/Composer/Downloader/VcsDownloader.php +++ b/src/Composer/Downloader/VcsDownloader.php @@ -215,9 +215,14 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa public function remove(PackageInterface $package, $path) { $this->io->writeError(" - " . UninstallOperation::format($package)); - if (!$this->filesystem->removeDirectory($path)) { - throw new \RuntimeException('Could not completely delete '.$path.', aborting.'); - } + + $promise = $this->filesystem->removeDirectoryAsync($path); + + return $promise->then(function($result) use ($path) { + if (!$result) { + throw new \RuntimeException('Could not completely delete '.$path.', aborting.'); + } + }); } /**