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