From 235e3480e651790feb63b904945db2dd352a4bde 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 304b2ccf46..d2232624b9 100644 --- a/lib/private/Files/Node/Node.php +++ b/lib/private/Files/Node/Node.php @@ -265,7 +265,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); } /**