bug #17195 bug #14246 [Filesystem] dumpFile() non atomic (Hidde Boomsma)

This PR was merged into the 2.3 branch.

Discussion
----------

bug #14246 [Filesystem] dumpFile() non atomic

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #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 #14246 [Filesystem] dumpFile() non atomic
This commit is contained in:
Nicolas Grekas 2015-12-31 10:05:40 +01:00
commit 3aa30005f0
1 changed files with 2 additions and 2 deletions

View File

@ -477,9 +477,9 @@ class Filesystem
throw new IOException(sprintf('Failed to write file "%s".', $filename));
}
$this->rename($tmpFile, $filename, true);
if (null !== $mode) {
$this->chmod($filename, $mode);
$this->chmod($tmpFile, $mode);
}
$this->rename($tmpFile, $filename, true);
}
}