1
0
Fork 0

Retry on RecursiveDirectoryIterator failure to open dir, refs #4009

pull/4961/merge
Jordi Boggiano 2016-02-28 14:06:36 +00:00
parent 823266407f
commit c502601c4b
1 changed files with 9 additions and 1 deletions

View File

@ -145,7 +145,15 @@ class Filesystem
*/ */
public function removeDirectoryPhp($directory) public function removeDirectoryPhp($directory)
{ {
$it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS); try {
$it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
} catch (\UnexpectedValueException $e) {
// re-try once after clearing the stat cache if it failed as it
// sometimes fails without apparent reason, see https://github.com/composer/composer/issues/4009
clearstatcache();
usleep(100000);
$it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
}
$ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST); $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
foreach ($ri as $file) { foreach ($ri as $file) {