This commit is contained in:
xl
2024-11-18 12:23:58 +08:00
parent b54d956a2d
commit e0eda4b42c
+6 -4
View File
@@ -78,7 +78,7 @@ class HotReload extends AbstractProcess
$read = inotify_read($this->pipe); $read = inotify_read($this->pipe);
foreach ($read as $item) { foreach ($read as $item) {
$this->reWatch($this->watches[$item['wd']]); $this->reWatch($this->watches[$item['mask']]);
} }
$this->reload(); $this->reload();
@@ -122,12 +122,14 @@ class HotReload extends AbstractProcess
* @param string $directory * @param string $directory
* @return void * @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_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;
} }
} }