Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2018-04-26 21:04:19 +0300
committerMikael Hammarin <mhammarin@ecit.com>2018-10-26 09:36:21 +0300
commitd8a581e4260cffe748c2da19959d80949ab57a83 (patch)
tree5daa7e32273b0f8679af57c965582d6f0880da7f /lib
parentae061c69f1bf1e4196a13ed9de88c6c438bce01c (diff)
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')
-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 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);
}
/**