From 2d40e14985d33e0d1e21bab3d2d48cf012d6ef07 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 11 Feb 2013 22:51:24 +0100 Subject: [PATCH] Try twice to remove a directory on windows because sometimes it fails due to temporary locks --- src/Composer/Downloader/FileDownloader.php | 5 ++++- src/Composer/Downloader/VcsDownloader.php | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Composer/Downloader/FileDownloader.php b/src/Composer/Downloader/FileDownloader.php index d05aa6ad2..372513331 100644 --- a/src/Composer/Downloader/FileDownloader.php +++ b/src/Composer/Downloader/FileDownloader.php @@ -171,7 +171,10 @@ class FileDownloader implements DownloaderInterface { $this->io->write(" - Removing " . $package->getName() . " (" . VersionParser::formatVersion($package) . ")"); if (!$this->filesystem->removeDirectory($path)) { - throw new \RuntimeException('Could not completely delete '.$path.', aborting.'); + // retry after a bit on windows since it tends to be touchy with mass removals + if (!defined('PHP_WINDOWS_VERSION_BUILD') || (usleep(250) && !$this->filesystem->removeDirectory($path))) { + throw new \RuntimeException('Could not completely delete '.$path.', aborting.'); + } } } diff --git a/src/Composer/Downloader/VcsDownloader.php b/src/Composer/Downloader/VcsDownloader.php index 55a189b7b..c9b8dc150 100644 --- a/src/Composer/Downloader/VcsDownloader.php +++ b/src/Composer/Downloader/VcsDownloader.php @@ -128,7 +128,10 @@ abstract class VcsDownloader implements DownloaderInterface $this->io->write(" - Removing " . $package->getName() . " (" . $package->getPrettyVersion() . ")"); $this->cleanChanges($path, false); if (!$this->filesystem->removeDirectory($path)) { - throw new \RuntimeException('Could not completely delete '.$path.', aborting.'); + // retry after a bit on windows since it tends to be touchy with mass removals + if (!defined('PHP_WINDOWS_VERSION_BUILD') || (usleep(250) && !$this->filesystem->removeDirectory($path))) { + throw new \RuntimeException('Could not completely delete '.$path.', aborting.'); + } } }