Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c9a0355

Browse files
committed
[HttpCache] Unlink tmp file on error
1 parent 509142e commit c9a0355

File tree

1 file changed

+6
-0
lines changed
  • src/Symfony/Component/HttpKernel/HttpCache

1 file changed

+6
-0
lines changed

src/Symfony/Component/HttpKernel/HttpCache/Store.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,16 +387,22 @@ private function save($key, $data)
387387

388388
$tmpFile = tempnam(dirname($path), basename($path));
389389
if (false === $fp = @fopen($tmpFile, 'wb')) {
390+
@unlink($tmpFile);
391+
390392
return false;
391393
}
392394
@fwrite($fp, $data);
393395
@fclose($fp);
394396

395397
if ($data != file_get_contents($tmpFile)) {
398+
@unlink($tmpFile);
399+
396400
return false;
397401
}
398402

399403
if (false === @rename($tmpFile, $path)) {
404+
@unlink($tmpFile);
405+
400406
return false;
401407
}
402408
}

0 commit comments

Comments
 (0)