Skip to content

Commit 3aa3000

Browse files
bug symfony#17195 bug symfony#14246 [Filesystem] dumpFile() non atomic (Hidde Boomsma)
This PR was merged into the 2.3 branch. Discussion ---------- bug symfony#14246 [Filesystem] dumpFile() non atomic | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#14246 | License | MIT | Doc PR | none Remove race condition where `dumpFile` has written the resulting file but has not given access yet. Commits ------- e4015d5 bug symfony#14246 [Filesystem] dumpFile() non atomic
2 parents 5ff8713 + e4015d5 commit 3aa3000

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,9 +477,9 @@ public function dumpFile($filename, $content, $mode = 0666)
477477
throw new IOException(sprintf('Failed to write file "%s".', $filename));
478478
}
479479

480-
$this->rename($tmpFile, $filename, true);
481480
if (null !== $mode) {
482-
$this->chmod($filename, $mode);
481+
$this->chmod($tmpFile, $mode);
483482
}
483+
$this->rename($tmpFile, $filename, true);
484484
}
485485
}

0 commit comments

Comments
 (0)