Merge pull request #9475 from nextcloud/bug/9469/delete_preview_on_version_restore
Delete the previews when a version is restored
This commit is contained in:
commit
0011bfb64b
3 changed files with 20 additions and 0 deletions
|
@ -337,6 +337,9 @@ class Storage {
|
|||
return false;
|
||||
}
|
||||
|
||||
// Fetch the userfolder to trigger view hooks
|
||||
$userFolder = \OC::$server->getUserFolder($uid);
|
||||
|
||||
$users_view = new View('/'.$uid);
|
||||
$files_view = new View('/'. User::getUser().'/files');
|
||||
|
||||
|
@ -375,9 +378,14 @@ class Storage {
|
|||
if (self::copyFileContents($users_view, $fileToRestore, 'files' . $filename)) {
|
||||
$files_view->touch($file, $revision);
|
||||
Storage::scheduleExpire($uid, $file);
|
||||
|
||||
$node = $userFolder->get($file);
|
||||
|
||||
// TODO: move away from those legacy hooks!
|
||||
\OC_Hook::emit('\OCP\Versions', 'rollback', array(
|
||||
'path' => $filename,
|
||||
'revision' => $revision,
|
||||
'node' => $node,
|
||||
));
|
||||
return true;
|
||||
} else if ($versionCreated) {
|
||||
|
|
|
@ -49,6 +49,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;
|
||||
|
@ -61,4 +65,10 @@ class Watcher {
|
|||
//Nothing to do
|
||||
}
|
||||
}
|
||||
|
||||
public function versionRollback(array $data) {
|
||||
if (isset($data['node'])) {
|
||||
$this->deleteNode($data['node']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,6 +60,8 @@ class WatcherConnector {
|
|||
$this->root->listen('\OC\Files', 'postWrite', function (Node $node) {
|
||||
$this->getWatcher()->postWrite($node);
|
||||
});
|
||||
|
||||
\OC_Hook::connect('\OCP\Versions', 'rollback', $this->getWatcher(), 'versionRollback');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue