From ce7a2117432b139551511fbb07805d3a9ddc2c67 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Thu, 26 Apr 2018 20:04:19 +0200 Subject: [PATCH] Actually return the root folder when traversing up the tree If you now keep calling $node->getParent() you will at some point get the RootFolder back. This is a nice termination check and will prevent endless loops if an exit condition is slightly off. Signed-off-by: Roeland Jago Douma --- lib/private/Files/Node/Node.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/private/Files/Node/Node.php b/lib/private/Files/Node/Node.php index e00debe6903..f01d2421d16 100644 --- a/lib/private/Files/Node/Node.php +++ b/lib/private/Files/Node/Node.php @@ -266,7 +266,11 @@ class Node implements \OCP\Files\Node { * @return Node */ public function getParent() { - return $this->root->get(dirname($this->path)); + $newPath = dirname($this->path); + if ($newPath === '' || $newPath === '.' || $newPath === '/') { + return $this->root; + } + return $this->root->get($newPath); } /**