-
Notifications
You must be signed in to change notification settings - Fork 235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#46 - applying correct chmod()
to generated cache file
#49
#46 - applying correct chmod()
to generated cache file
#49
Conversation
Oh shit, never thought about that :-( |
@bjoernhaeuser no big deal, this happens all the time. |
👍 |
@@ -208,6 +210,7 @@ private function saveCacheFile($path, $data) | |||
throw new \RuntimeException(sprintf('Unable to rename %s to %s', $tempfile, $path)); | |||
} | |||
|
|||
@chmod($path, 0666 & ~umask()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this way the chmod
is done after the rename, making the operation not atomic. Consider moving it to before the rename
block.
chmod($tempfile, 0666 & ~umask());
if (false === rename($tempfile, $path)) {
throw new \RuntimeException(sprintf('Unable to rename %s to %s', $tempfile, $path));
}
Not sure why the @ would be needed, so removed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Windows cannot chmod. So if you don't silence the error, things will break on Windows
👍, encountered the same bug. |
You have an error with your commit ! This is your code: if (false === rename($tempfile, $path)) {
throw new \RuntimeException(sprintf('Unable to rename %s to %s', $tempfile, $path));
}
@unlink($tempfile);
The correct fix would be:
$newTempFile = rename($tempfile, $path);
if (false === $newTempFile) {
throw new \RuntimeException(sprintf('Unable to rename %s to %s', $tempfile, $path));
}
@unlink($newTempFile);
The error generated with your commit is this:
|
@edouardkombo in case the |
…missions #46 - applying correct `chmod()` to generated cache file
See #46 ( #46 (comment) )