summaryrefslogtreecommitdiffstats
path: root/lib/private/Files/Node/Node.php
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2018-04-26 20:04:19 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2018-04-26 20:04:19 +0200
commit235e3480e651790feb63b904945db2dd352a4bde (patch)
tree61c3571d232b71b8b76d106b0f594f169b62a149 /lib/private/Files/Node/Node.php
parentbb82bfac6dd388fac21284b7996eaa31cc44d55f (diff)
downloadnextcloud-server-235e3480e651790feb63b904945db2dd352a4bde.tar.gz
nextcloud-server-235e3480e651790feb63b904945db2dd352a4bde.zip
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 <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/Files/Node/Node.php')
-rw-r--r--lib/private/Files/Node/Node.php6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/private/Files/Node/Node.php b/lib/private/Files/Node/Node.php
index 304b2ccf464..d2232624b9b 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);
}
/**