[HttpCache] Unlink tmp file on error

This commit is contained in:
Chansig 2018-03-31 09:59:49 +02:00
parent 509142e7c9
commit c9a0355883
1 changed files with 6 additions and 0 deletions

View File

@ -387,16 +387,22 @@ class Store implements StoreInterface
$tmpFile = tempnam(dirname($path), basename($path));
if (false === $fp = @fopen($tmpFile, 'wb')) {
@unlink($tmpFile);
return false;
}
@fwrite($fp, $data);
@fclose($fp);
if ($data != file_get_contents($tmpFile)) {
@unlink($tmpFile);
return false;
}
if (false === @rename($tmpFile, $path)) {
@unlink($tmpFile);
return false;
}
}