From a4dab661c0a34e98893aee11aefeac2b0d0028f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Thu, 3 Sep 2020 01:34:21 +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 --- system/Process/ServerInotify.php | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/system/Process/ServerInotify.php b/system/Process/ServerInotify.php index 0d40eff2..61b474b6 100644 --- a/system/Process/ServerInotify.php +++ b/system/Process/ServerInotify.php @@ -63,16 +63,17 @@ class ServerInotify extends Process { $this->debug('file modify listener.'); - $this->loadByDir(APP_PATH . 'app'); + $this->loadByDir(APP_PATH . 'app', true); } /** * @param $path + * @param bool $isReload * @return void * @throws Exception */ - private function loadByDir($path) + private function loadByDir($path, $isReload = false) { $path = rtrim($path, '/'); foreach (glob($path . '/*') as $value) { @@ -82,15 +83,19 @@ class ServerInotify extends Process } $md5 = md5($value); if (!isset($this->md5Map[$md5])) { - $this->debug('not hav ' . $value); - return $this->reload(); + if ($isReload) { + return $this->reload(); + } + $this->md5Map[$md5] = filectime($value); + } else { + $mTime = filectime($value); + if ($this->md5Map[$md5] != $mTime) { + if ($isReload) { + return $this->reload(); + } + $this->md5Map[$md5] = filectime($value); + } } - $mTime = filectime($value); - if ($this->md5Map[$md5] != $mTime) { - $this->debug('not hav ' . $this->md5Map[$md5] . ':' . $mTime); - return $this->reload(); - } - $this->md5Map[$md5] = $mTime; } }