From e0eda4b42c11c8fe29d7ebec9c515fdd9288fd16 Mon Sep 17 00:00:00 2001 From: xl Date: Mon, 18 Nov 2024 12:23:58 +0800 Subject: [PATCH] eee --- Abstracts/HotReload.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Abstracts/HotReload.php b/Abstracts/HotReload.php index a9842c7..b6bb2d9 100644 --- a/Abstracts/HotReload.php +++ b/Abstracts/HotReload.php @@ -78,7 +78,7 @@ class HotReload extends AbstractProcess $read = inotify_read($this->pipe); foreach ($read as $item) { - $this->reWatch($this->watches[$item['wd']]); + $this->reWatch($this->watches[$item['mask']]); } $this->reload(); @@ -122,12 +122,14 @@ class HotReload extends AbstractProcess * @param string $directory * @return void */ - public function reWatch(string $directory): void + public function reWatch(int $directory): void { - if (str_ends_with($directory, '.php') === true) { + if (isset($this->watches[$directory])) { inotify_rm_watch($this->pipe, $directory); - inotify_add_watch($this->pipe, $directory, IN_MODIFY | IN_MOVE | IN_CREATE | IN_DELETE); + $wd = inotify_add_watch($this->pipe, $directory, IN_MODIFY | IN_MOVE | IN_CREATE | IN_DELETE); + + $this->watches[$wd] = $directory; } }