[HttpCache] Unlink tmp file on error
This commit is contained in:
parent
509142e7c9
commit
c9a0355883
|
@ -387,16 +387,22 @@ class Store implements StoreInterface
|
||||||
|
|
||||||
$tmpFile = tempnam(dirname($path), basename($path));
|
$tmpFile = tempnam(dirname($path), basename($path));
|
||||||
if (false === $fp = @fopen($tmpFile, 'wb')) {
|
if (false === $fp = @fopen($tmpFile, 'wb')) {
|
||||||
|
@unlink($tmpFile);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@fwrite($fp, $data);
|
@fwrite($fp, $data);
|
||||||
@fclose($fp);
|
@fclose($fp);
|
||||||
|
|
||||||
if ($data != file_get_contents($tmpFile)) {
|
if ($data != file_get_contents($tmpFile)) {
|
||||||
|
@unlink($tmpFile);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (false === @rename($tmpFile, $path)) {
|
if (false === @rename($tmpFile, $path)) {
|
||||||
|
@unlink($tmpFile);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue