Эх сурвалжийг харах

Try twice to remove a directory on windows because sometimes it fails due to temporary locks

Jordi Boggiano 12 жил өмнө
parent
commit
2d40e14985

+ 4 - 1
src/Composer/Downloader/FileDownloader.php

@@ -171,7 +171,10 @@ class FileDownloader implements DownloaderInterface
     {
         $this->io->write("  - Removing <info>" . $package->getName() . "</info> (<comment>" . VersionParser::formatVersion($package) . "</comment>)");
         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.');
+            }
         }
     }
 

+ 4 - 1
src/Composer/Downloader/VcsDownloader.php

@@ -128,7 +128,10 @@ abstract class VcsDownloader implements DownloaderInterface
         $this->io->write("  - Removing <info>" . $package->getName() . "</info> (<comment>" . $package->getPrettyVersion() . "</comment>)");
         $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.');
+            }
         }
     }