Skip to content

Commit

Permalink
minor #13645 fixed possible race condition when creating a directory …
Browse files Browse the repository at this point in the history
…(fabpot)

This PR was merged into the 2.3 branch.

Discussion
----------

fixed possible race condition when creating a directory

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #13228
| License       | MIT
| Doc PR        | n/a

Commits
-------

8542866 fixed possible race condition when creating a directory
  • Loading branch information
fabpot committed Feb 16, 2015
2 parents ee47901 + 8542866 commit e18d2ad
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Expand Up @@ -666,7 +666,7 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde

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));
}

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpFoundation/File/File.php
Expand Up @@ -130,7 +130,7 @@ public function move($directory, $name = null)
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)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpKernel/Kernel.php
Expand Up @@ -605,7 +605,7 @@ protected function buildContainer()
{
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)) {
Expand Down

0 comments on commit e18d2ad

Please sign in to comment.