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:
parent
ce4927b92b
commit
ce7a211743
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue