mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-08 23:52:49 +08:00
优化File缓存自动生成空目录的问题
This commit is contained in:
8
library/think/cache/driver/File.php
vendored
8
library/think/cache/driver/File.php
vendored
@@ -64,9 +64,10 @@ class File extends Driver
|
|||||||
* 取得变量的存储文件名
|
* 取得变量的存储文件名
|
||||||
* @access protected
|
* @access protected
|
||||||
* @param string $name 缓存变量名
|
* @param string $name 缓存变量名
|
||||||
|
* @param bool $auto 是否自动创建目录
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getCacheKey($name)
|
protected function getCacheKey($name, $auto = false)
|
||||||
{
|
{
|
||||||
$name = md5($name);
|
$name = md5($name);
|
||||||
if ($this->options['cache_subdir']) {
|
if ($this->options['cache_subdir']) {
|
||||||
@@ -78,7 +79,8 @@ class File extends Driver
|
|||||||
}
|
}
|
||||||
$filename = $this->options['path'] . $name . '.php';
|
$filename = $this->options['path'] . $name . '.php';
|
||||||
$dir = dirname($filename);
|
$dir = dirname($filename);
|
||||||
if (!is_dir($dir)) {
|
|
||||||
|
if ($auto && !is_dir($dir)) {
|
||||||
mkdir($dir, 0755, true);
|
mkdir($dir, 0755, true);
|
||||||
}
|
}
|
||||||
return $filename;
|
return $filename;
|
||||||
@@ -144,7 +146,7 @@ class File extends Driver
|
|||||||
if ($expire instanceof \DateTime) {
|
if ($expire instanceof \DateTime) {
|
||||||
$expire = $expire->getTimestamp() - time();
|
$expire = $expire->getTimestamp() - time();
|
||||||
}
|
}
|
||||||
$filename = $this->getCacheKey($name);
|
$filename = $this->getCacheKey($name, true);
|
||||||
if ($this->tag && !is_file($filename)) {
|
if ($this->tag && !is_file($filename)) {
|
||||||
$first = true;
|
$first = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user