Skip to content

Commit

Permalink
fix: pass string value to function getNodeForPath()
Browse files Browse the repository at this point in the history
Signed-off-by: Luka Trovic <luka@nextcloud.com>
  • Loading branch information
luka-nextcloud committed Aug 1, 2023
1 parent 9241a38 commit 91a0f59
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions lib/private/Files/Node/HookConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ public function viewToNode() {
}

public function write($arguments) {
if (!is_string($arguments['path'])) {
return;
}

$node = $this->getNodeForPath($arguments['path']);
$this->root->emit('\OC\Files', 'preWrite', [$node]);
$this->dispatcher->dispatch('\OCP\Files::preWrite', new GenericEvent($node));
Expand All @@ -101,6 +105,10 @@ public function write($arguments) {
}

public function postWrite($arguments) {
if (!is_string($arguments['path'])) {
return;
}

$node = $this->getNodeForPath($arguments['path']);
$this->root->emit('\OC\Files', 'postWrite', [$node]);
$this->dispatcher->dispatch('\OCP\Files::postWrite', new GenericEvent($node));
Expand All @@ -110,6 +118,10 @@ public function postWrite($arguments) {
}

public function create($arguments) {
if (!is_string($arguments['path'])) {
return;
}

$node = $this->getNodeForPath($arguments['path']);
$this->root->emit('\OC\Files', 'preCreate', [$node]);
$this->dispatcher->dispatch('\OCP\Files::preCreate', new GenericEvent($node));
Expand All @@ -119,6 +131,10 @@ public function create($arguments) {
}

public function postCreate($arguments) {
if (!is_string($arguments['path'])) {
return;
}

$node = $this->getNodeForPath($arguments['path']);
$this->root->emit('\OC\Files', 'postCreate', [$node]);
$this->dispatcher->dispatch('\OCP\Files::postCreate', new GenericEvent($node));
Expand All @@ -128,6 +144,10 @@ public function postCreate($arguments) {
}

public function delete($arguments) {
if (!is_string($arguments['path'])) {
return;
}

$node = $this->getNodeForPath($arguments['path']);
$this->deleteMetaCache[$node->getPath()] = $node->getFileInfo();
$this->root->emit('\OC\Files', 'preDelete', [$node]);
Expand All @@ -138,6 +158,10 @@ public function delete($arguments) {
}

public function postDelete($arguments) {
if (!is_string($arguments['path'])) {
return;
}

$node = $this->getNodeForPath($arguments['path']);
unset($this->deleteMetaCache[$node->getPath()]);
$this->root->emit('\OC\Files', 'postDelete', [$node]);
Expand All @@ -148,6 +172,10 @@ public function postDelete($arguments) {
}

public function touch($arguments) {
if (!is_string($arguments['path'])) {
return;
}

$node = $this->getNodeForPath($arguments['path']);
$this->root->emit('\OC\Files', 'preTouch', [$node]);
$this->dispatcher->dispatch('\OCP\Files::preTouch', new GenericEvent($node));
Expand All @@ -157,6 +185,10 @@ public function touch($arguments) {
}

public function postTouch($arguments) {
if (!is_string($arguments['path'])) {
return;
}

$node = $this->getNodeForPath($arguments['path']);
$this->root->emit('\OC\Files', 'postTouch', [$node]);
$this->dispatcher->dispatch('\OCP\Files::postTouch', new GenericEvent($node));
Expand All @@ -166,6 +198,10 @@ public function postTouch($arguments) {
}

public function rename($arguments) {
if (!is_string($arguments['oldpath']) || !is_string($arguments['newpath'])) {
return;
}

$source = $this->getNodeForPath($arguments['oldpath']);
$target = $this->getNodeForPath($arguments['newpath']);
$this->root->emit('\OC\Files', 'preRename', [$source, $target]);
Expand All @@ -176,6 +212,10 @@ public function rename($arguments) {
}

public function postRename($arguments) {
if (!is_string($arguments['oldpath']) || !is_string($arguments['newpath'])) {
return;
}

$source = $this->getNodeForPath($arguments['oldpath']);
$target = $this->getNodeForPath($arguments['newpath']);
$this->root->emit('\OC\Files', 'postRename', [$source, $target]);
Expand All @@ -186,6 +226,10 @@ public function postRename($arguments) {
}

public function copy($arguments) {
if (!is_string($arguments['oldpath']) || !is_string($arguments['newpath'])) {
return;
}

$source = $this->getNodeForPath($arguments['oldpath']);
$target = $this->getNodeForPath($arguments['newpath']);
$this->root->emit('\OC\Files', 'preCopy', [$source, $target]);
Expand All @@ -196,6 +240,10 @@ public function copy($arguments) {
}

public function postCopy($arguments) {
if (!is_string($arguments['oldpath']) || !is_string($arguments['newpath'])) {
return;
}

$source = $this->getNodeForPath($arguments['oldpath']);
$target = $this->getNodeForPath($arguments['newpath']);
$this->root->emit('\OC\Files', 'postCopy', [$source, $target]);
Expand All @@ -206,6 +254,10 @@ public function postCopy($arguments) {
}

public function read($arguments) {
if (!is_string($arguments['path'])) {
return;
}

$node = $this->getNodeForPath($arguments['path']);
$this->root->emit('\OC\Files', 'read', [$node]);
$this->dispatcher->dispatch('\OCP\Files::read', new GenericEvent([$node]));
Expand Down

0 comments on commit 91a0f59

Please sign in to comment.