mirror of
https://github.com/mrclay/minify.git
synced 2025-08-11 08:34:19 +02:00
Corrupted cache files are now deleted.
This commit is contained in:
@@ -82,7 +82,7 @@ class Minify_Cache_File {
|
||||
|
||||
/**
|
||||
* Write data to file and verify its contents
|
||||
*
|
||||
*
|
||||
* @param string $file path
|
||||
*
|
||||
* @param string $data
|
||||
@@ -91,8 +91,13 @@ class Minify_Cache_File {
|
||||
*/
|
||||
private static function _verifiedWrite($file, $data)
|
||||
{
|
||||
return (file_put_contents($file, $data, LOCK_EX)
|
||||
&& (md5($data) === md5_file($file))
|
||||
);
|
||||
if (! @file_put_contents($file, $data, LOCK_EX)) {
|
||||
return false;
|
||||
}
|
||||
if (md5($data) !== md5_file($file)) {
|
||||
@unlink($file);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user