修复并发创建目录报错的问题

This commit is contained in:
Karson
2025-07-10 10:05:04 +08:00
parent d08729b040
commit d32996a0d5

View File

@@ -150,12 +150,19 @@ class File extends SplFileObject
*/ */
protected function checkPath($path) protected function checkPath($path)
{ {
if (is_dir($path) || mkdir($path, 0755, true)) { if (is_dir($path)) {
return true;
}
if (@mkdir($path, 0755, true)) {
return true;
}
if (is_dir($path)) {
return true; return true;
} }
$this->error = ['directory {:path} creation failed', ['path' => $path]]; $this->error = ['directory {:path} creation failed', ['path' => $path]];
return false; return false;
} }