aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Preview
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Preview')
-rw-r--r--lib/private/Preview/Watcher.php3
-rw-r--r--lib/private/Preview/WatcherConnector.php32
2 files changed, 13 insertions, 22 deletions
diff --git a/lib/private/Preview/Watcher.php b/lib/private/Preview/Watcher.php
index abddd7b5acb..21f040d8342 100644
--- a/lib/private/Preview/Watcher.php
+++ b/lib/private/Preview/Watcher.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
*/
namespace OC\Preview;
+use OCP\Files\FileInfo;
use OCP\Files\Folder;
use OCP\Files\IAppData;
use OCP\Files\Node;
@@ -37,7 +38,7 @@ class Watcher {
$this->deleteNode($node);
}
- protected function deleteNode(Node $node) {
+ protected function deleteNode(FileInfo $node) {
// We only handle files
if ($node instanceof Folder) {
return;
diff --git a/lib/private/Preview/WatcherConnector.php b/lib/private/Preview/WatcherConnector.php
index ae2a136ca78..c34dd1dde4d 100644
--- a/lib/private/Preview/WatcherConnector.php
+++ b/lib/private/Preview/WatcherConnector.php
@@ -9,43 +9,33 @@ declare(strict_types=1);
namespace OC\Preview;
use OC\SystemConfig;
+use OCA\Files_Versions\Events\VersionRestoredEvent;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\IRootFolder;
use OCP\Files\Node;
class WatcherConnector {
- /** @var IRootFolder */
- private $root;
-
- /** @var SystemConfig */
- private $config;
-
- /**
- * WatcherConnector constructor.
- *
- * @param IRootFolder $root
- * @param SystemConfig $config
- */
- public function __construct(IRootFolder $root,
- SystemConfig $config) {
- $this->root = $root;
- $this->config = $config;
+ public function __construct(
+ private IRootFolder $root,
+ private SystemConfig $config,
+ private IEventDispatcher $dispatcher,
+ ) {
}
- /**
- * @return Watcher
- */
private function getWatcher(): Watcher {
return \OCP\Server::get(Watcher::class);
}
- public function connectWatcher() {
+ 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) {
$this->getWatcher()->postWrite($node);
});
- \OC_Hook::connect('\OCP\Versions', 'rollback', $this->getWatcher(), 'versionRollback');
+ $this->dispatcher->addListener(VersionRestoredEvent::class, function (VersionRestoredEvent $event) {
+ $this->getWatcher()->versionRollback(['node' => $event->getVersion()->getSourceFile()]);
+ });
}
}
}