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>
This commit is contained in:
Roeland Jago Douma 2018-04-26 20:04:19 +02:00
parent bb82bfac6d
commit 235e3480e6
No known key found for this signature in database
GPG key ID: F941078878347C0C

View file

@ -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);
}
/**