diff --git a/src/ZM/Store/FileSystem.php b/src/ZM/Store/FileSystem.php index 8ce7e3e7..4efc2fea 100644 --- a/src/ZM/Store/FileSystem.php +++ b/src/ZM/Store/FileSystem.php @@ -25,6 +25,11 @@ class FileSystem logger()->warning(zm_internal_errcode('E00080') . '扫描目录失败,目录不存在'); return false; } + // 检查目录是否可读 + if (!is_readable($dir)) { + logger()->warning(zm_internal_errcode('E00080') . '扫描目录失败,目录不可读'); + return false; + } logger()->debug('扫描' . $dir); // 套上 zm_dir $scan_list = scandir($dir); diff --git a/tests/ZM/Store/FileSystemTest.php b/tests/ZM/Store/FileSystemTest.php index ea295ace..f21f3972 100644 --- a/tests/ZM/Store/FileSystemTest.php +++ b/tests/ZM/Store/FileSystemTest.php @@ -127,7 +127,7 @@ class FileSystemTest extends TestCase $old_perm = $this->vfs->getPermissions(); $this->vfs->chmod(0000); FileSystem::scanDirFiles($this->vfs->url()); - $this->assertLogged('warning', zm_internal_errcode('E00080') . '扫描目录失败,目录无法读取: ' . $this->vfs->url()); + $this->assertLogged('warning', zm_internal_errcode('E00080') . '扫描目录失败,目录不可读'); $this->vfs->chmod($old_perm); } }