Skip to content
Permalink
Browse files

Revert "saveCache() is atomic [Closes #11]"

This reverts commit b703b4f.
  • Loading branch information
dg committed Feb 12, 2020
1 parent 180f89e commit 01c0c643ba89c9def919e792b004985003a7b27a
Showing with 2 additions and 3 deletions.
  1. +2 −3 src/RobotLoader/RobotLoader.php
@@ -438,10 +438,9 @@ private function loadCache(): void
private function saveCache(): void
{
$file = $this->getCacheFile();
$tempFile = $file . uniqid('', true) . '.tmp';
$code = "<?php\nreturn " . var_export([$this->classes, $this->missing], true) . ";\n";
if (file_put_contents($tempFile, $code) !== strlen($code) || !rename($tempFile, $file)) {
@unlink($tempFile); // @ - file may not exist
if (file_put_contents("$file.tmp", $code) !== strlen($code) || !rename("$file.tmp", $file)) {
@unlink("$file.tmp"); // @ - file may not exist
throw new \RuntimeException("Unable to create '$file'.");
}
if (function_exists('opcache_invalidate')) {

0 comments on commit 01c0c64

Please sign in to comment.
You can’t perform that action at this time.