diff --git a/Filesystem.php b/Filesystem.php index b46f5a2..eb594f1 100644 --- a/Filesystem.php +++ b/Filesystem.php @@ -1413,8 +1413,16 @@ protected function prepareDirectoryStructure($file) } if (!$res) { - $oct = ($perm === false) ? '777' : decoct($perm); $err = ErrorHandler::stop(); + + // Issue 6435: + // mkdir could fail because of a race condition it was already created by another process + // after the first file_exists above + if (file_exists($pathname)) { + return; + } + + $oct = ($perm === false) ? '777' : decoct($perm); throw new Exception\RuntimeException("mkdir('{$pathname}', 0{$oct}, true) failed", 0, $err); } @@ -1452,6 +1460,14 @@ protected function prepareDirectoryStructure($file) } if (!$res) { + + // Issue 6435: + // mkdir could fail because of a race condition it was already created by another process + // after the first file_exists above ... go to the next path part. + if (file_exists($path)) { + continue; + } + $oct = ($perm === false) ? '777' : decoct($perm); ErrorHandler::stop(); throw new Exception\RuntimeException(