make Node::getParent lazy

Signed-off-by: Robin Appelman <robin@icewind.nl>
pull/38150/head
Robin Appelman 2023-05-09 17:11:20 +07:00
parent 0232eec2cf
commit e718cbc661
No known key found for this signature in database
GPG Key ID: 42B69D8A64526EFB
1 changed files with 10 additions and 1 deletions

@ -300,7 +300,16 @@ class Node implements INode {
return $this->root;
}
$this->parent = $this->root->get($newPath);
$parentData = [
'path' => $newPath,
];
if ($this->fileInfo instanceof \OC\Files\FileInfo && isset($this->fileInfo['parent'])) {
$parentData['fileid'] = $this->fileInfo['parent'];
}
$this->parent = new LazyFolder(function () use ($newPath) {
return $this->root->get($newPath);
}, $parentData);
}
return $this->parent;