diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2018-05-14 20:58:19 +0300 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-05-26 15:09:11 +0300 |
commit | d33834f07a274889cb174f4117dccd6f0e5f61d3 (patch) | |
tree | 4550463ce8bac2e6dd3c1ca9733c255e864a0679 /lib | |
parent | 043acfebab11e4fdfdda9f412543f3d08b30c33c (diff) |
Delete the previews when a version is restored
Fixes #9469
When a version of a file is restored the previews are no longer valid.
Thus we should remove them so they are regenerated.
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Preview/Watcher.php | 10 | ||||
-rw-r--r-- | lib/private/Preview/WatcherConnector.php | 2 |
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/private/Preview/Watcher.php b/lib/private/Preview/Watcher.php index 8d091b84b0e..893f60a86e5 100644 --- a/lib/private/Preview/Watcher.php +++ b/lib/private/Preview/Watcher.php @@ -52,6 +52,10 @@ class Watcher { } public function postWrite(Node $node) { + $this->deleteNode($node); + } + + protected function deleteNode(Node $node) { // We only handle files if ($node instanceof Folder) { return; @@ -101,4 +105,10 @@ class Watcher { } } } + + public function versionRollback(array $data) { + if (isset($data['node'])) { + $this->deleteNode($data['node']); + } + } } diff --git a/lib/private/Preview/WatcherConnector.php b/lib/private/Preview/WatcherConnector.php index 4e6e786cec7..735aaba41a9 100644 --- a/lib/private/Preview/WatcherConnector.php +++ b/lib/private/Preview/WatcherConnector.php @@ -67,6 +67,8 @@ class WatcherConnector { $this->root->listen('\OC\Files', 'postDelete', function (Node $node) { $this->getWatcher()->postDelete($node); }); + + \OC_Hook::connect('\OCP\Versions', 'rollback', $this->getWatcher(), 'versionRollback'); } } } |