Fix FileWatcher timer sentinel handling

This commit is contained in:
2026-07-08 13:49:46 +08:00
parent 55d50b7bff
commit a61e83ff6a
+4 -4
View File
@@ -183,12 +183,12 @@ class FileWatcher extends AbstractProcess implements OnProcessInterface
$this->fswatchPipes = []; $this->fswatchPipes = [];
$this->stopFswatchProcess(); $this->stopFswatchProcess();
if ($this->pollTimer) { if ($this->pollTimer > 0) {
Timer::clear($this->pollTimer); Timer::clear($this->pollTimer);
$this->pollTimer = -1; $this->pollTimer = -1;
} }
if ($this->debounceTimer) { if ($this->debounceTimer > 0) {
Timer::clear($this->debounceTimer); Timer::clear($this->debounceTimer);
$this->debounceTimer = -1; $this->debounceTimer = -1;
} }
@@ -267,7 +267,7 @@ class FileWatcher extends AbstractProcess implements OnProcessInterface
return; return;
} }
if ($this->debounceTimer) { if ($this->debounceTimer > 0) {
Timer::clear($this->debounceTimer); Timer::clear($this->debounceTimer);
} }
@@ -276,7 +276,7 @@ class FileWatcher extends AbstractProcess implements OnProcessInterface
$delay = max($this->debounceMs, $this->minReloadIntervalMs - $elapsed); $delay = max($this->debounceMs, $this->minReloadIntervalMs - $elapsed);
$this->debounceTimer = Timer::after($delay, function () use ($changedFiles) { $this->debounceTimer = Timer::after($delay, function () use ($changedFiles) {
$this->debounceTimer = null; $this->debounceTimer = -1;
$this->reload($changedFiles); $this->reload($changedFiles);
}); });
} }