Merge pull request #9622 from nextcloud/backport/9475/stable13
[stable13] Delete the previews when a version is restored
This commit is contained in:
commit
8889220f55
|
@ -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) {
|
||||
|
|
|
@ -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']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue