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 committed by Mikael Hammarin
parent ae061c69f1
commit d8a581e426
1 changed files with 5 additions and 1 deletions

View File

@ -266,7 +266,11 @@ class Node implements \OCP\Files\Node {
* @return Node * @return Node
*/ */
public function getParent() { 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);
} }
/** /**