删除不存在的File缓存时异常

增加删除本地文件缓存时优先判断是否存在,如果存在则进行unlink删除操作
This commit is contained in:
xiaobo.sun
2016-02-14 16:25:24 +08:00
parent c211d0859e
commit f637f06e0d

View File

@@ -104,7 +104,7 @@ class File
$expire = (int) substr($content, 8, 12);
if (0 != $expire && time() > filemtime($filename) + $expire) {
//缓存过期删除缓存文件
unlink($filename);
$this->unlink($filename);
return false;
}
$content = substr($content, 20, -3);
@@ -157,7 +157,7 @@ class File
// 出列
$key = array_shift($queue);
// 删除缓存
unlink($this->filename($key));
$this->unlink($this->filename($key));
}
file_put_contents($queue_file, serialize($queue));
}
@@ -176,7 +176,7 @@ class File
*/
public function rm($name)
{
return unlink($this->filename($name));
return $this->unlink($this->filename($name));
}
/**
@@ -191,7 +191,7 @@ class File
while ($file = readdir($dir)) {
$check = is_dir($file);
if (!$check) {
unlink($path . $file);
$this->unlink($path . $file);
}
}
@@ -199,4 +199,16 @@ class File
return true;
}
}
/**
* 判断文件是否存在后,删除
* @param $path
* @return bool
* @author byron sampson <xiaobo.sun@qq.com>
* @return boolean
*/
private function unlink($path)
{
return is_file($path) && unlink($path);
}
}