fixed possible race condition when creating a directory
This commit is contained in:
parent
9a70bbbdb2
commit
8542866dde
@ -666,7 +666,7 @@ class FrameworkExtension extends Extension
|
||||
|
||||
if ('file' === $config['cache']) {
|
||||
$cacheDir = $container->getParameterBag()->resolveValue($config['file_cache_dir']);
|
||||
if (!is_dir($cacheDir) && false === @mkdir($cacheDir, 0777, true)) {
|
||||
if (!is_dir($cacheDir) && false === @mkdir($cacheDir, 0777, true) && !is_dir($cacheDir)) {
|
||||
throw new \RuntimeException(sprintf('Could not create cache directory "%s".', $cacheDir));
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ class File extends \SplFileInfo
|
||||
protected function getTargetFile($directory, $name = null)
|
||||
{
|
||||
if (!is_dir($directory)) {
|
||||
if (false === @mkdir($directory, 0777, true)) {
|
||||
if (false === @mkdir($directory, 0777, true) && !is_dir($directory)) {
|
||||
throw new FileException(sprintf('Unable to create the "%s" directory', $directory));
|
||||
}
|
||||
} elseif (!is_writable($directory)) {
|
||||
|
@ -605,7 +605,7 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
{
|
||||
foreach (array('cache' => $this->getCacheDir(), 'logs' => $this->getLogDir()) as $name => $dir) {
|
||||
if (!is_dir($dir)) {
|
||||
if (false === @mkdir($dir, 0777, true)) {
|
||||
if (false === @mkdir($dir, 0777, true) && !is_dir($dir)) {
|
||||
throw new \RuntimeException(sprintf("Unable to create the %s directory (%s)\n", $name, $dir));
|
||||
}
|
||||
} elseif (!is_writable($dir)) {
|
||||
|
Reference in New Issue
Block a user