[Filesystem Component] mkdir race condition fix #11626

This commit is contained in:
Ka 2014-08-19 10:20:36 +02:00 committed by Fabien Potencier
parent b674e678db
commit 04834521f1
1 changed files with 8 additions and 1 deletions

View File

@ -78,7 +78,14 @@ class Filesystem
}
if (true !== @mkdir($dir, $mode, true)) {
throw new IOException(sprintf('Failed to create %s', $dir));
$error = error_get_last();
if (!is_dir($dir)) {
// The directory was not created by a concurrent process. Let's throw an exception with a developer friendly error message if we have one
if ($error) {
throw new IOException(sprintf('Failed to create "%s": %s.', $dir, $error['message']));
}
throw new IOException(sprintf('Failed to create "%s"', $dir));
}
}
}
}