From 6391a9e2adeecfb084fc7085cfdfee929635267f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Mon, 7 Sep 2020 16:28:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HttpServer/Server.php | 1 + System/Snowflake.php | 12 ++++++++++++ function.php | 3 +++ 3 files changed, 16 insertions(+) diff --git a/HttpServer/Server.php b/HttpServer/Server.php index 81468979..bb8026e2 100644 --- a/HttpServer/Server.php +++ b/HttpServer/Server.php @@ -97,6 +97,7 @@ class Server extends Application return $this->error_stop($config['host'], $config['port']); } } + Snowflake::clearWorkerId(); $baseServer = $this->initCore($configs); $baseServer->start(); } diff --git a/System/Snowflake.php b/System/Snowflake.php index 01029f3b..1709846c 100644 --- a/System/Snowflake.php +++ b/System/Snowflake.php @@ -141,6 +141,18 @@ class Snowflake } + /** + * @throws Exception + */ + public static function clearWorkerId() + { + $dir = storage(null, 'worker'); + foreach (glob($dir . '/*') as $file) { + @unlink($file); + } + } + + /** * @param $fileName * @param $content diff --git a/function.php b/function.php index 0b9e3210..960749d5 100644 --- a/function.php +++ b/function.php @@ -164,6 +164,9 @@ if (!function_exists('storage')) { } else { $fileName = rtrim(initDir($basePath, $path)) . '/' . $fileName; } + if (empty($fileName)) { + return $path; + } if (!file_exists($fileName)) { touch($fileName); }