continue = false; }); $this->instance = inotify_init(); stream_set_blocking($this->instance, 0); $this->resourceHandle = inotify_add_watch( $this->instance, $watchDir, IN_CLOSE_WRITE | IN_ATTRIB | IN_MOVED_TO | IN_MOVE_SELF, ); while ($this->continue) { $events = inotify_read($this->instance); if (!empty($events)) { // Get filenames only and remove duplicates $fileNames = array_unique( array_map(function ($event) { return $event["name"]; }, $events), ); foreach ($fileNames as $fileName) { echo $fileName . PHP_EOL; SendToImmichJob::dispatch($fileName); } } sleep(1); } fclose($this->instance); } }