Skip to content

Commit

Permalink
make Node::getParent lazy
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 committed Aug 14, 2023
1 parent 7820c16 commit 5bc261b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/private/Files/Node/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,16 @@ public function getParent(): INode|IRootFolder {
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;
Expand Down

0 comments on commit 5bc261b

Please sign in to comment.