watcher !== null) { return $this->watcher; } $this->watcher = Server::get(Watcher::class); return $this->watcher; } public function connectWatcher(): void { // Do not connect if we are not setup yet! if ($this->config->getValue('instanceid', null) !== null) { $this->root->listen('\OC\Files', 'postWrite', function (Node $node): void { $this->getWatcher()->postWrite($node); }); $this->dispatcher->addListener(VersionRestoredEvent::class, function (VersionRestoredEvent $event): void { $this->getWatcher()->versionRollback(['node' => $event->getVersion()->getSourceFile()]); }); } } }